hugo_server

Hugo provides its own webserver which builds and serves the site. While hugo server is high performance, it is a webserver with limited options. Many run it in production, but the standard behavior is for people to use it in development and use a more full featured server such as Nginx or Caddy.

‘hugo server’ will avoid writing the rendered and served content to disk, preferring to store it in memory.

Org Roam content is exported as markdown files using ox-hugo and these markdown files are served by hugo server.

Hugo ↗ server is installed using Alpine Linux package manager. On Note6Pro this was installed within termux .

Use Hugo to serve as website locally

hugo_server can be run locally to serve as a local webserver to serve the local Arch and any other computers , using the content exported by ox-hugo .

Hugo server must be started at the site-directory: Initially, this was data/docs/prabu/Dropbox/org/quickstart

In early'26, a new site was created with hugo-book theme at /data/myhome/prabu/Dropbox/org/my_hugo_site.

prabu@homepc2 /d/d/p/D/o/quickstart (master)> hugo server --buildDrafts --navigateToChanged
Watching for changes in /data/docs/prabu/Dropbox/org/quickstart/{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in /data/docs/prabu/Dropbox/org/quickstart/hugo.toml, /data/docs/prabu/Dropbox/org/quickstart/themes/ananke/config.yaml
Start building sites …
hugo v0.124.0+extended linux/amd64 BuildDate=unknown


                   | EN
-------------------+------
  Pages            | 107
  Paginator pages  |   9
  Non-page files   |   0
  Static files     |   1
  Processed images |   0
  Aliases          |   1
  Cleaned          |   0

Built in 146 ms
Environment: "development"
Serving pages from disk
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Hugo server can generate static website content in html in addition to rendering html from markdown files.

Steps to generate html site

When the hugo server is run as follows, it generates html files for all the equivalent md files in public folder. This concept is used in hugo-watcher service.

$hugo -D

Remove the older content

To ensure that all the older contents are removed, remove the public folder.

prabu@homepc2 /d/d/p/D/o/quickstart (master)> pwd
/data/docs/prabu/Dropbox/org/quickstart
prabu@homepc2 /d/d/p/D/o/quickstart (master)> rm -rf public/

enable ugly URL’s.

Edit the the hugo.toml file to enable ugly URL’s.

# To temporarily generete single page static website uncomment below line
# uglyURLs = true

Hugo Tutorial

Followed the first four segments of the following tutorial when learning about hugo initially. https://cloudcannon.com/tutorials/hugo-beginner-tutorial/ ↗

hugo-watcher

A service script named hugo-watcher was created to generate html whenever new content is created from emacs. Disabled this later due to synchronisation issues with syncthing .

  prabu@homepc2 ~> cat /etc/init.d/hugo-watcher
#!/sbin/openrc-run

# Adjust these paths to your actual setup
HUGO_DIR="/data/myhome/prabu/Dropbox/org/my_hugo_site"
HUGO_USER="prabu"
HUGO_GROUP="prabu"

name="Hugo Watcher"
description="Rebuilds Hugo site on file changes"
command="/usr/bin/hugo"
# We use --source and --destination to point to site directory
command_args="--source ${HUGO_DIR} --destination ${HUGO_DIR}/public --watch --cleanDestinationDir -D --quiet"
command_user="${HUGO_USER}:${HUGO_GROUP}"
command_background="yes"
pidfile="/run/hugo-watcher.pid"


depend() {
    need localmount
    after bootmisc
}

Manual Trigger

Due to repeated issues with syncthing and hugo_watcher service, disabled the hugo_watcher service. I went with a manual publishing function with the following script. A custom function to run this added to Emacs .

prabu@homepc2 ~> cat /data/myhome/prabu/Dropbox/org/my_hugo_site/scripts/publish_hugo_site.sh
#!/bin/sh
SAVED_KEY=$(grep "SYNCTHING_API_KEY" /home/prabu/.config/syncthing/apikey | cut -d'"' -f2)
Hugo_site="/data/myhome/prabu/Dropbox/org/my_hugo_site"
# Generate the json required to update the graph
python3 "$Hugo_site/scripts/gen_graph.py"
# Build the Site using hugo
/usr/bin/hugo --source "$Hugo_site" --destination "$Hugo_site/public" -D
#Force Syncthing to sync org-Roam folder
curl -s -X POST -H "X-API-Key:$SAVED_KEY" "http://localhost:8384/rest/db/scan?folder=scwmx-w9vj5"
echo "Build complete. Syncthing scan triggered."

using rclone with hugo

Using the rclone + rcx combination, synced the quickstart directory from the local pc to mobile.

Source: https://foosel.net/blog/2023-01-21-hugo-meet-android/ ↗


© Prabu Anand K 2020-2026