newContentEditor not working as expected?

I recently discovered the newContentEditor configuration setting, but for some reason I can’t seem to get it to work. I’ve added this to my config.toml:

NewContentEditor = "code"

In theory, this should launch Visual Studio Code when adding new content with hugo new post/, but in my case (on macOS Mojave) it creates the post file, but does not open it in Visual Studio Code.

If I run it “manually” with hugo new post/ --editor=code it works as expected, so the Visual Studio Code binary is in my path, and can be called just by typing in code.


Try using the case as shown in the docs

newContentEditor = “code”

If only it was that easy, I’ve tried with no avail.

Show your full config.toml

Try moving that line to right beneath disqusShortname.

By the way, I have this working locally in a sample project. I created a new site and edited my config.toml to be:

baseURL = ""
languageCode = "en-us"
title = "My New Hugo Site"
newContentEditor = "code"

I think in your case, your newContentEditor = "code" line was below [[]] and so was being treated as part of it.

FYI you can search your hugo config settings to see the value of a particular config option.

On Unix-like systems:

hugo config | grep -i "newContentEditor"

On Windows:

hugo config | findstr /i "newContentEditor"

You’re right! Moving it up fixed the issue. Awesome, thanks a lot!

This is a typical TOML thing. Arrays or Tables are closed by the next or the EOF. See more great infos here:

Yeah, makes sense really! I just didn’t think of it.