Integrating HUGO into TFS Azure DevOps
My blog is being built by HUGO. Up until today - I have made my markup files and then manually run hugo - and then copied the files to my fileserver in the DMZ zone of my network.
Being lazy I wanted to look into how I could make this more automatic.
So my goals were:
- Open visual studio
- Add a new .md file
- commit & push to my git repository
- Get a build triggered automatically that built and pushed to my file server
So I started by openening visual studio and open my folder where I had the blog located.
This gave me nothing of any help - except for a UI for git, which was not really critical - but nice enough.
So I started looking for a visual studio extension that could give some sort of help with markdown files - and I found this that my old collegue Mads Kristensen had made Markdown Editor.
Perfect - now I could edit markdown and get a preview of what I had written.
Then the next task - find a Azure DevOps extension that could do what I have done manually, which is basically run hugo.
Luckily enough someone has made a nice extension that does all that: Hugo by Giulio Vian
That is easy to use - just tell it what source folder and destination folder and you are good to go
Its as easy as adding the task to the build pipeline like this:
That worked perfectly - now HUGO runs every time I commit and push something to my blog git repository.
Last bit is getting the output from HUGO copied to my fileserver - which is luckily enough also easy, since I could just use a “Copy files over SSH” task:
So very easy overall - of course if your fileserver is not a linux server, then you should use a different Copy files task - but the end result is the same.
I can now commit a new blog post to my git repository and a minute later its online on my blog.