← Back
Mischa Vandenburg May 9, 2023 17m

How I Write & Publish My Blog Using Neovim & Hugo From The Command Line

Read full transcript 12 segments
  1. hello welcome back uh I was about to hello welcome back uh I was about to make a little blog post on my website make a little blog post on my website make a little blog post on my website and I figured I would show you how I do and I figured I would show you how I do and I figured I would show you how I do that how I actually write blog posts and that how I actually write blog posts and that how I actually write blog posts and publish them all from the command line publish them all from the command line publish them all from the command line so the uh to start off let's just show so the uh to start off let's just show so the uh to start off let's just show you I'll just show you my blog here this you I'll just show you my blog here this you I'll just show you my blog here this is my website is my website is my website this is more like a public subtle this is more like a public subtle this is more like a public subtle casting where I just published the casting where I just published the casting where I just published the things that I'm learning I write notes things that I'm learning I write notes things that I'm learning I write notes on what I do and then I publish them on what I do and then I publish them on what I do and then I publish them here sometimes I write a bit longer here sometimes I write a bit longer here sometimes I write a bit longer articles and sometimes I just share articles and sometimes I just share articles and sometimes I just share something really short and small like something really short and small like something really short and small like this like you can abort operations on this like you can abort operations on this like you can abort operations on AKs clusters now I found that useful and AKs clusters now I found that useful and AKs clusters now I found that useful and I wanted to save that and share that I wanted to save that and share that I wanted to save that and share that with any potential others that are with any potential others that are with any potential others that are reading my website so check it out this reading my website so check it out this reading my website so check it out this you can check out the start here page you can check out the start here page you can check out the start here page and there I've written all about why I and there I've written all about why I and there I've written all about why I do this and and how do this and and how do this and and how so the thing that I'm that I want to so the thing that I'm that I want to so the thing that I'm that I want to share on my blog is something I've been share on my blog is something I've been share on my blog is something I've been meaning to do for months but I just meaning to do for months but I just meaning to do for months but I just haven't really gotten around to it but haven't really gotten around to it but haven't really gotten around to it but this this weather to check the weather this this weather to check the weather this this weather to check the weather from the terminal from the terminal from the terminal so and to do that you do you use a curl so and to do that you do you use a curl so and to do that you do you use a curl command and you curl wttr.in and it shows you this very pretty uh and it shows you this very pretty uh overview of the weather for today overview of the weather for today overview of the weather for today tomorrow and the day after that and

  2. tomorrow and the day after that and tomorrow and the day after that and there's all sorts of ways you can there's all sorts of ways you can there's all sorts of ways you can modulate this so if I believe it's slash modulate this so if I believe it's slash modulate this so if I believe it's slash Amsterdam Amsterdam Amsterdam yeah and then it will show you the yeah and then it will show you the yeah and then it will show you the weather in Amsterdam weather in Amsterdam weather in Amsterdam and let's check out what the weather in and let's check out what the weather in and let's check out what the weather in Oslo is going to be like Oslo is going to be like Oslo is going to be like it's actually a light rain and shower it's actually a light rain and shower it's actually a light rain and shower there now and it looks like it's going there now and it looks like it's going there now and it looks like it's going to be pretty decent weather there as to be pretty decent weather there as to be pretty decent weather there as well so that's that's nice and check it well so that's that's nice and check it well so that's that's nice and check it out on uh whatever out on uh whatever out on uh whatever there's a GitHub there's a GitHub there's a GitHub yeah here's a GitHub repo yeah here's a GitHub repo yeah here's a GitHub repo and you can actually and you can actually and you can actually modulate how to how small you wanted modulate how to how small you wanted modulate how to how small you wanted what you want and it's a really neat what you want and it's a really neat what you want and it's a really neat application you can you can embed things application you can you can embed things application you can you can embed things in your con key or things or other in your con key or things or other in your con key or things or other things that you have on your screen things that you have on your screen things that you have on your screen you can format it like let's try this you can format it like let's try this you can format it like let's try this one and then you just get one line so yeah and then you just get one line so yeah it's really neat so I figured I would it's really neat so I figured I would it's really neat so I figured I would make a blog post on that make a blog post on that make a blog post on that so I'll start with so I'll start with so I'll start with um just increasing my um just increasing my um just increasing my font size here font size here font size here so this is that little script that I so this is that little script that I so this is that little script that I wrote in the previous video and now it wrote in the previous video and now it wrote in the previous video and now it has increased the font size has increased the font size has increased the font size and the what I what I use for my blog is

  3. and the what I what I use for my blog is and the what I what I use for my blog is something called Hugo something called Hugo something called Hugo you go you go you go yeah what is it you you go static yeah what is it you you go static yeah what is it you you go static website generator website generator website generator here we go go hugo.io here we go go hugo.io here we go go hugo.io it's a really neat way to produce it's a really neat way to produce it's a really neat way to produce websites because everything is done from websites because everything is done from websites because everything is done from local markdown files local markdown files local markdown files so with you you go you uh so with you you go you uh so with you you go you uh make it you choose a theme and then you make it you choose a theme and then you make it you choose a theme and then you feed markdown files into it and it will feed markdown files into it and it will feed markdown files into it and it will generate the website for you generate the website for you generate the website for you so to show you what that looks like I'll so to show you what that looks like I'll so to show you what that looks like I'll go to my blog repo go to my blog repo go to my blog repo uh this is actually a GitHub repo that uh this is actually a GitHub repo that uh this is actually a GitHub repo that contains everything that I uh that contains everything that I uh that contains everything that I uh that contains my entire website and contains my entire website and contains my entire website and saddlecasting so yeah it's uh you can saddlecasting so yeah it's uh you can saddlecasting so yeah it's uh you can read about Hugo how it works but read about Hugo how it works but read about Hugo how it works but basically you have a config file and you basically you have a config file and you basically you have a config file and you just configure it like this you have to just configure it like this you have to just configure it like this you have to add a theme but then there is the add a theme but then there is the add a theme but then there is the content directory and as you see here this contains and as you see here this contains markdown files markdown files markdown files so so so here let's just open up one here CLI here let's just open up one here CLI here let's just open up one here CLI choking in moment well this is just a choking in moment well this is just a choking in moment well this is just a short set that I wrote a while ago and short set that I wrote a while ago and short set that I wrote a while ago and let's do the other one this is the one

  4. let's do the other one this is the one let's do the other one this is the one that I published this morning so this is that I published this morning so this is that I published this morning so this is what the the markdown file looks like it what the the markdown file looks like it what the the markdown file looks like it has a bit of front matter and a date and has a bit of front matter and a date and has a bit of front matter and a date and a few tags and if I go back to my a few tags and if I go back to my a few tags and if I go back to my website you will see here website you will see here website you will see here that here is are the tags that I added that here is are the tags that I added that here is are the tags that I added there and it has the date and it has there and it has the date and it has there and it has the date and it has this uh this uh this uh title and this is how how you write an title and this is how how you write an title and this is how how you write an article for how you write a post for you article for how you write a post for you article for how you write a post for you go so it takes all of these po all these go so it takes all of these po all these go so it takes all of these po all these markdown files and renders it to a markdown files and renders it to a markdown files and renders it to a static website static website static website and you can have tags so I have a tag go and you can have tags so I have a tag go and you can have tags so I have a tag go here and it will sort everything uh here and it will sort everything uh here and it will sort everything uh with everything every post that I've with everything every post that I've with everything every post that I've given the tag go it will show you that given the tag go it will show you that given the tag go it will show you that that particular tag that list of tags so that particular tag that list of tags so that particular tag that list of tags so it's it's really handy I really like it's it's really handy I really like it's it's really handy I really like Hugo I tried a few different things but Hugo I tried a few different things but Hugo I tried a few different things but this is a really neat way to do it and this is a really neat way to do it and this is a really neat way to do it and in order to in order to in order to yeah actually do this I wrote my own yeah actually do this I wrote my own yeah actually do this I wrote my own script to uh to facilitate this because script to uh to facilitate this because script to uh to facilitate this because what Hugo does it takes the markdown what Hugo does it takes the markdown what Hugo does it takes the markdown files and it converts it to a static files and it converts it to a static files and it converts it to a static HTML website so uh in the in the repo HTML website so uh in the in the repo HTML website so uh in the in the repo where I was where I am where I was where I am where I was where I am here you have the the content directory

  5. here you have the the content directory here you have the the content directory but there's also the static directory but there's also the static directory but there's also the static directory and no and no and no Pub the public directory excuse me if I Pub the public directory excuse me if I Pub the public directory excuse me if I go to the public directory here you will go to the public directory here you will go to the public directory here you will actually see the site map and the index actually see the site map and the index actually see the site map and the index HTML so let's see what that looks like HTML so let's see what that looks like HTML so let's see what that looks like so this is the actual uh generated so this is the actual uh generated so this is the actual uh generated content that the website that that you content that the website that that you content that the website that that you go generated so that's just a quick go generated so that's just a quick go generated so that's just a quick overview of how that works overview of how that works overview of how that works and to and to and to actually write a blog post I have made actually write a blog post I have made actually write a blog post I have made myself a little script and myself a little script and myself a little script and it's called blog and I do blog set it's called blog and I do blog set it's called blog and I do blog set and then I can enter a file name so I'll and then I can enter a file name so I'll and then I can enter a file name so I'll do check weather terminal do check weather terminal do check weather terminal and then it opens up a new markdown file and then it opens up a new markdown file and then it opens up a new markdown file in neovim of course with a template that in neovim of course with a template that in neovim of course with a template that I created I created I created so how I will now I will just do the so how I will now I will just do the so how I will now I will just do the actual writing so I'll do how to check actual writing so I'll do how to check actual writing so I'll do how to check the weather from the command line the weather from the command line the weather from the command line and I'll give that the tags command line and I'll give that the tags command line and I'll give that the tags command line um um um productivity and I'll throw in Linux and I'll throw in Linux why not so why not so why not so um then I write uh yeah um then I write uh yeah um then I write uh yeah for the past few months I've been using

  6. for the past few months I've been using for the past few months I've been using this neat this neat this neat API to check the weather from the API to check the weather from the API to check the weather from the terminal it's very simple it's very simple to use to use to use simply enter simply simply and simply run and simply run and simply run curl the the wtr.in so this will curl the the wtr.in so this will curl the the wtr.in so this will will will will show the weather based on your location show the weather based on your location show the weather based on your location but you can also but you can also but you can also um um um you can also give a particular you can also give a particular you can also give a particular location and format location and format location and format so curl so curl so curl dot i n slash Amsterdam dot i n slash Amsterdam dot i n slash Amsterdam just as an example like that so like that so then I like to include then I like to include then I like to include some links with my some links with my some links with my um with my posts so then I will just um with my posts so then I will just um with my posts so then I will just include the link for include the link for include the link for this GitHub repo like this this GitHub repo like this this GitHub repo like this and save that and that's that so this and save that and that's that so this and save that and that's that so this link section it also has this unique link section it also has this unique link section it also has this unique identifier in it that's because all of identifier in it that's because all of identifier in it that's because all of these articles or all of these zets they these articles or all of these zets they these articles or all of these zets they are integrated into my private are integrated into my private are integrated into my private saddlecasting as well so I I there's saddlecasting as well so I I there's saddlecasting as well so I I there's just a portion of my Zeal castle that I

  7. just a portion of my Zeal castle that I just a portion of my Zeal castle that I publish publish publish and now that I have written this I can and now that I have written this I can and now that I have written this I can save it like that save it like that save it like that and then what I can do is I run the blog and then what I can do is I run the blog and then what I can do is I run the blog reset command and I'll I'll go through reset command and I'll I'll go through reset command and I'll I'll go through the script afterwards but the blog reset the script afterwards but the blog reset the script afterwards but the blog reset command basically deletes the old command basically deletes the old command basically deletes the old website that is locally stored and then website that is locally stored and then website that is locally stored and then it serves up a copy at localhost so this it serves up a copy at localhost so this it serves up a copy at localhost so this is just a development server and if I is just a development server and if I is just a development server and if I then go here to localhost 1313 then we then go here to localhost 1313 then we then go here to localhost 1313 then we have the new blog post here have the new blog post here have the new blog post here so how to check the weather from the so how to check the weather from the so how to check the weather from the command line for the password mounts command line for the password mounts command line for the password mounts I've been using this neat API check the I've been using this neat API check the I've been using this neat API check the weather from the terminal it's very weather from the terminal it's very weather from the terminal it's very simple to use simple to use simple to use um so some most often I'll just publish um so some most often I'll just publish um so some most often I'll just publish it straight away to the internet but it straight away to the internet but it straight away to the internet but sometimes I want to check it locally sometimes I want to check it locally sometimes I want to check it locally just to make sure that everything went just to make sure that everything went just to make sure that everything went well well well and uh also just to show you I can open and uh also just to show you I can open and uh also just to show you I can open it like this it like this it like this and and and if I were to if I were to if I were to um um um make a adjustment here make a adjustment here make a adjustment here so here I use the word terminal but so here I use the word terminal but so here I use the word terminal but let's change that to command line and if let's change that to command line and if let's change that to command line and if I then write I then write I then write you see that the word actually changed you see that the word actually changed you see that the word actually changed here in the local version of the website

  8. here in the local version of the website here in the local version of the website so sometimes it's nice to check that so sometimes it's nice to check that so sometimes it's nice to check that first before you publish first before you publish first before you publish so now that's done I've added the the so now that's done I've added the the so now that's done I've added the the [Music] [Music] [Music] the the the the the the new post new post new post so just to make sure I'll go to my so just to make sure I'll go to my so just to make sure I'll go to my website here you will see that this is website here you will see that this is website here you will see that this is the the new the the latest article here the the new the the latest article here the the new the the latest article here and now I will run my custom command and now I will run my custom command and now I will run my custom command called blog Pub called blog Pub called blog Pub and I'll enter a commit message so I'll and I'll enter a commit message so I'll and I'll enter a commit message so I'll just do weather command just do weather command just do weather command line line line so this script does a few things for me it this script does a few things for me it deletes the old website it then deletes the old website it then deletes the old website it then regenerates the website with the new regenerates the website with the new regenerates the website with the new content content content and then it copies that over to a and then it copies that over to a and then it copies that over to a different repository that I have hooked different repository that I have hooked different repository that I have hooked up to my web hosting so I'll walk you up to my web hosting so I'll walk you up to my web hosting so I'll walk you through that as well but first let's see through that as well but first let's see through that as well but first let's see what the result is so I hear I'm on my what the result is so I hear I'm on my what the result is so I hear I'm on my actual live website on the internet and actual live website on the internet and actual live website on the internet and I'll refresh this I'll refresh this I'll refresh this and here we go how to check the weather and here we go how to check the weather and here we go how to check the weather from the command line it's uh it's from the command line it's uh it's from the command line it's uh it's already live already live already live so how this works is I I have this local so how this works is I I have this local so how this works is I I have this local repo and I can also show you that on repo and I can also show you that on repo and I can also show you that on GitHub GitHub GitHub as well as well as well um um um this is my main GitHub page and I'll

  9. this is my main GitHub page and I'll this is my main GitHub page and I'll just show you the blog repo here it's uh just show you the blog repo here it's uh just show you the blog repo here it's uh it's all openly available you can look it's all openly available you can look it's all openly available you can look at the source code if you want at the source code if you want at the source code if you want and and and um um um here you will see the commit message so here you will see the commit message so here you will see the commit message so I one minute ago I just made that I one minute ago I just made that I one minute ago I just made that weather command line and it will show weather command line and it will show weather command line and it will show you that I actually added this uh this you that I actually added this uh this you that I actually added this uh this markdown file here markdown file here markdown file here and then I have a different repo that is and then I have a different repo that is and then I have a different repo that is uh uh uh blog blog blog hosting so it's a different one and this hosting so it's a different one and this hosting so it's a different one and this contains the what we saw in the public contains the what we saw in the public contains the what we saw in the public folder the public directory that I folder the public directory that I folder the public directory that I showed you a few minutes ago showed you a few minutes ago showed you a few minutes ago so this is just the actual statically so this is just the actual statically so this is just the actual statically generated website and this is hooked up generated website and this is hooked up generated website and this is hooked up to my hosting provider so my hosting to my hosting provider so my hosting to my hosting provider so my hosting provider gives me a plus instance and provider gives me a plus instance and provider gives me a plus instance and here I go to git and this is hooked up here I go to git and this is hooked up here I go to git and this is hooked up to this Tech blog hosting repository to this Tech blog hosting repository to this Tech blog hosting repository that I have that I have that I have and it every time I I push to that repo and it every time I I push to that repo and it every time I I push to that repo then a web Hook is triggered and then it then a web Hook is triggered and then it then a web Hook is triggered and then it will pull the repo and it will will pull the repo and it will will pull the repo and it will um publish the new content so it's very um publish the new content so it's very um publish the new content so it's very easy very very com convenient to easy very very com convenient to easy very very com convenient to um to publish content and I do it all

  10. um to publish content and I do it all um to publish content and I do it all from the command line as you see I write from the command line as you see I write from the command line as you see I write my even for longer articles I do all my my even for longer articles I do all my my even for longer articles I do all my writing in in neovim and writing in in neovim and writing in in neovim and it is just a very convenient comfortable it is just a very convenient comfortable it is just a very convenient comfortable way of of working for me so um way of of working for me so um way of of working for me so um I created this nice little workflow for I created this nice little workflow for I created this nice little workflow for myself around it and it works very well myself around it and it works very well myself around it and it works very well for me so I'll just quickly go over that for me so I'll just quickly go over that for me so I'll just quickly go over that blog script that I blog script that I blog script that I [Music] [Music] [Music] showed you showed you showed you so I wrote this myself it's just a bash so I wrote this myself it's just a bash so I wrote this myself it's just a bash script script script and it is and it is and it is it takes a few parameters so here I have it takes a few parameters so here I have it takes a few parameters so here I have a function that will read the file name a function that will read the file name a function that will read the file name and store it in a variable and store it in a variable and store it in a variable and here is the open file which will and here is the open file which will and here is the open file which will open the file in a certain directory and open the file in a certain directory and open the file in a certain directory and here it is setting up the yaml front here it is setting up the yaml front here it is setting up the yaml front matter it is a little bit caveman style matter it is a little bit caveman style matter it is a little bit caveman style where I just do it line by line and where I just do it line by line and where I just do it line by line and maybe later I'll create some nice maybe later I'll create some nice maybe later I'll create some nice template actually elsewhere I've already template actually elsewhere I've already template actually elsewhere I've already done something different where I done something different where I done something different where I do a cat eof for example like this so do a cat eof for example like this so do a cat eof for example like this so maybe I should just redo this section maybe I should just redo this section maybe I should just redo this section but it formats the front matter like we but it formats the front matter like we but it formats the front matter like we saw and then it opens the file in neovim saw and then it opens the file in neovim saw and then it opens the file in neovim and so and so and so here I have set up how the arguments are

  11. here I have set up how the arguments are here I have set up how the arguments are are done so if are done so if are done so if um in bash this is how you refer to the um in bash this is how you refer to the um in bash this is how you refer to the arguments from the command line arguments from the command line arguments from the command line and here when when I when it sees that and here when when I when it sees that and here when when I when it sees that in that array then it will in that array then it will in that array then it will um um um do this and open a set Style do this and open a set Style do this and open a set Style of a template and then I also have an of a template and then I also have an of a template and then I also have an article template which will open then article template which will open then article template which will open then here's the reset command that you saw me here's the reset command that you saw me here's the reset command that you saw me using so it will using so it will using so it will delete the content of the public delete the content of the public delete the content of the public directory it will enter the blog directory it will enter the blog directory it will enter the blog directory and then it will run the Hugo directory and then it will run the Hugo directory and then it will run the Hugo and Hugo server command to regenerate and Hugo server command to regenerate and Hugo server command to regenerate the website and here is the the pub the website and here is the the pub the website and here is the the pub command where it will command where it will command where it will um um um regenerate the website and push that regenerate the website and push that regenerate the website and push that commit to the respective repositories commit to the respective repositories commit to the respective repositories so this script is publicly available so this script is publicly available so this script is publicly available it's on my if you want to have a look at it's on my if you want to have a look at it's on my if you want to have a look at it it's in my it it's in my it it's in my um dot files repo um dot files repo um dot files repo over here dot files and over here dot files and over here dot files and Scripts Scripts Scripts here you will find blog so here you will find blog so here you will find blog so that's uh that's uh that's uh that's very quickly how I how I manage that's very quickly how I how I manage that's very quickly how I how I manage my blog from the command line so my blog from the command line so my blog from the command line so hopefully this can be of inspiration to hopefully this can be of inspiration to hopefully this can be of inspiration to you I'm really happy with the choice you I'm really happy with the choice you I'm really happy with the choice with Hugo I think it's a very uh very with Hugo I think it's a very uh very with Hugo I think it's a very uh very good uh way to host a sort of text based

  12. good uh way to host a sort of text based good uh way to host a sort of text based uh text focused blog it's very uh text focused blog it's very uh text focused blog it's very comfortable to work with very easy to comfortable to work with very easy to comfortable to work with very easy to get going and of course it's written in get going and of course it's written in get going and of course it's written in go so that's always a very big plus but go so that's always a very big plus but go so that's always a very big plus but the the greatest thing about this is the the greatest thing about this is the the greatest thing about this is that you have everything stored in as that you have everything stored in as that you have everything stored in as local markdown files so whatever happens local markdown files so whatever happens local markdown files so whatever happens I first of all it's stored in git so I first of all it's stored in git so I first of all it's stored in git so it's always there but whatever happens I it's always there but whatever happens I it's always there but whatever happens I always have this content that directory always have this content that directory always have this content that directory where all of my things are stored as where all of my things are stored as where all of my things are stored as markdown files so it's not all HTML I markdown files so it's not all HTML I markdown files so it's not all HTML I don't have to write the HTML myself but don't have to write the HTML myself but don't have to write the HTML myself but I can use these markdown files and I can use these markdown files and I can use these markdown files and convert them to a different format later convert them to a different format later convert them to a different format later if I so desire so if I so desire so if I so desire so check it out hopefully it's been useful check it out hopefully it's been useful check it out hopefully it's been useful and this is how I publish on my blog so and this is how I publish on my blog so and this is how I publish on my blog so thank you for watching and see you in thank you for watching and see you in thank you for watching and see you in the next one

Summary

The main theme is how to publish blog posts and useful terminal commands from the command line. Key subjects include using `curl wttr.in` to display weather information and Hugo for static website generation. The practical takeaway is that you can streamline content creation and sharing by leveraging command-line tools and static site generators.

View original episode ↗