Now that I can run the site locally, I needed a quick way to run the hugo
command for creating new blog posts. After quick search on the internet, I found the article Tasks in Visual Studio Code very helpful. In short, I had to define the build task this way:
|
|
This task executes the hugo
command which generates your website to the public/
directory by default and makes it ready to be deployed to your web server. The --source
argument ensures the correct folder is built. In addition, setting "kind": "build"
and "isDefault": true
ensures that this task is executed with the Ctrl+Shift+B keyboard shortcut.
Next, I added another task to run the site locally:
|
|
This task executes the hugo server
command. The -D
flag ensures that we can preview content in draft mode, and again, the --source
argument ensures the correct folder is served. It’s important to note that the Serve
does not have "isDefault": true
since we do not want the two tasks to conflict when using the Ctrl+Shift+B keyboard shortcut.
So far I’m pretty pleased with my experience with the Hugo static site generator.