A couple of times each year someone expresses interest in creating a site that can be navigated via the file system. For example:
google-chrome public/en/index.html
Crafting and configuring a “serverless” site is not a trivial exercise for infrequent or casual users. Among other things, you need to:
- Set
baseURL = "/"
in site configuration - Set
uglyURLs = true
in site configuration - Set
relativeURLs = true
in site configuration - Remove
integrity
attributes onlink
andscript
elements - Work around #7497 when rendering menus, language switchers, etc.
And the setup varies depending on the number of languages and hosts.
In my view, in the majority of cases, the effort required exceeds the value obtained, particularly if you are trying to modify an existing theme. Using Hugo’s built-in development server, or something like the Node.js serve package, is almost always a better choice than trying to build a “serverless” site.
Having said that, here are some simple examples of serverless sites:
Monolingual site
git clone --single-branch -b hugo-forum-topic-48029-monolingual https://github.com/jmooring/hugo-testing hugo-forum-topic-48029-monolingual
cd hugo-forum-topic-48029-monolingual
# To build and view the site in "serverless" mode:
hugo -e serverless && google-chrome public/index.html
# To build and view the site in "server" mode:
hugo server
# To build the production site:
hugo
Multilingual single-host site
git clone --single-branch -b hugo-forum-topic-48029-multilingual-single-host https://github.com/jmooring/hugo-testing hugo-forum-topic-48029-multilingual-single-host
cd hugo-forum-topic-48029-multilingual-single-host
# To build and view the site in "serverless" mode:
hugo -e serverless && google-chrome public/en/index.html
# To build and view the site in "server" mode:
hugo server
# To build the production site:
hugo
Multilingual multi-host site
git clone --single-branch -b hugo-forum-topic-48029-multilingual-multi-host https://github.com/jmooring/hugo-testing hugo-forum-topic-48029-multilingual-multi-host
cd hugo-forum-topic-48029-multilingual-multi-host
# To build and view the site in "serverless" mode:
hugo -e serverless && google-chrome public/en/index.html
# To build and view the site in "server" mode:
hugo server
# To build the production site:
hugo