There are two methods to launch an editor upon content creation:
--editorcommand line flag. Example:
hugo new --editor gedit content/en/post/foo.md
newContentEditorin site configuration. Example:
newContentEditor = 'gedit'
Regardless of method, additional site configuration is required due to the enhanced security measures implemented in Hugo v0.90.0.
First, you must must add the editor to
security.exec.allow. If you forget to do this, Hugo will throw a descriptive error with instructions to address the problem.
For example, to use the
[security.exec] allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$', '^gedit$']
Second, you may have to add one or more operating system environment variables to
security.exec.osEnv. This will depend on your operating system, the editor that you have specified, and potentially several other factors such as how the editor was installed, or even how Hugo was installed.
For example, with
gedit on Ubuntu, I had to add
[security.exec] osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM|DISPLAY)$']
If the required environment variables are not included in
security.exec.osEnv, the editor will not launch. In some cases the failure will be silent, while in others the editor may throw an error. It can take some effort, including trial and error, to determine which environment variable(s) must be added to
security.exec.osEnv for different scenarios.
Given the variations described above, I thought it would be useful to keep track of what has worked for others.
|Editor||Operating System||Env Vars to Add to security.exec.osEnv|
|gedit||Ubuntu 20.04 LTS||
|nano||Ubuntu 20.04 LTS||none required|
|subl||Ubuntu 20.04 LTS||
I will try to keep this table updated to reflect comments on this topic.