created on | January 18, 2022 |
last modified on | June 28, 2022 |
Running HUGO server on host idoru, IP 192.168.0.10, port 1414
by default, HUGO logs to . You can log to a file with the parameter , i.e.:
When running HUGO in server mode, then by default HUGO creates a cache directory named in the systems temp dir, which on Linux is usually . This cache directory is used by HUGO to cache generated pages. Instead of using the default location for the cache, you can specify the cache directory with the parameter . You can prevent HUGO to use a cache for generated pages with the option .
When running several instances of HUGO in server mode on the same machine, you should set the cache directory explicitly with and start each HUGO dev servers with a different cache location. Starting several HUGO dev servers with the default cache location on the same machine will result one of the following Problems:
If you started HUGO in the foreground, HUGO will run and log to the terminal screen until you
press
Starting HUGO with specified port, log file, cache_dir, IP and base URL will look like:
which is a bit much to type. I usually run hugo in the background, as I don’t care about hugo’s terminal output as long as thing go fine. To stop the HUGO dev server, I have to look up it’s PID to kill it, which is also a bit tedious. I’ve written a script named to start and stop HUGO in server mode, which you can download here (see below).
I also use the script for collaborating with others on the same site, locally. With a terminal program and a user account on my machine, others can use my toolchain. It’s fun sitting next to each other, while working simultaneously on different versions of one site.
to install the script:
You can start HUGO in server mode with and stop the dev server with .
The hugoctl config file has six values. All values are mandatory and the config file must reside in the root of your site project (the directory where your site’s config.toml or config.yaml usually resides).
The config file I use for developing this site on my laptop which has the hostname idoru and the the IP 192.168.0.10 in my LAN, has the following content:
The config file is sourced by hugoctl, so in the last line of the config file above, is expanded to the value of in line 1, which results in the value for .
Run or to list the options and config parameters of .
symptom
Running results in the following runtime error:
cause
The most probable cause is insufficient read/write permissions for files and directories where Hugo creates its cache directory and log file.
fix
Check read and write permissions to log files and cache directory.