Run Hugo in a VSCode task

23 June 2020

I’m looking for ways to increase my focus and reduce the time I waste on “non important tasks”.
With this simple configuration, I don’t have to boot another terminal nor memorize Hugo’s parameters.

Create a tasks file

Create a file .vscode/tasks.json in your project. Add the following:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Start Dev",
      "type": "shell",
      "command": "hugo serve -D",
      "problemMatcher": []
    }
  ]
}

This defines a task called Start Dev.

Run the task

Bring up the Command Palette with Cmd + SHIFT + P. Type Run Task and select your task on the list.

If vscode asks how to parse the output, select "Never scan the task output for this task". VSCode will start your Hugo server in a shell.

Add more tasks

It’s not as powerful as a Makefile, not as javascripty as a package.json, but it does the job.
I can just open my project and run task.

More details in vscode documentation Integrate with External Tools via Tasks.

Let me know if you implement tasks more clever than this one!


Laurent Senta

I wrote software for large distributed systems, web applications, and even robots. These days I focus on making developers, creators, and humans more productive through IPDX.co.