← Alle Anleitungen
Hugo static site with Nginx
Hugo is one of the fastest static site generators available — write content in Markdown, generate a complete site in milliseconds, and serve the resulting plain HTML files with Nginx for maximum speed and minimal attack surface.
Zielsystem: Ubuntu 22.04 LTS / 24.04 LTSstatic-site-generatorNginxMarkdownOffizielle Website ↗Offizielle Dokumentation ↗
Diese Anleitung basiert auf der offiziellen Dokumentation von Hugo static site with Nginx, oben verlinkt — überprüfe dort immer die genauen Paket-/Versionsnamen, bevor du diese Befehle auf einem Produktionsserver ausführst, da sich Distributions- und Projektversionen mit der Zeit ändern.
1Install Hugo
sudo apt updatesudo apt install -y hugo2Create and build a new site
Hugo scaffolds a full project structure, and `hugo` (with no arguments) builds it into a `public/` folder of plain static HTML/CSS/JS.
hugo new site mysitecd mysitegit submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/anankeecho "theme = 'ananke'" >> hugo.tomlhugo3Serve the built site with Nginx
Point Nginx's root directly at Hugo's public/ output folder -- there's no PHP, no database, and nothing else running at request time.
sudo apt install -y nginxsudo cp -r public/* /var/www/html/Rebuild and re-copy the public/ folder (or automate it with a CI pipeline) every time content changes -- unlike a CMS, a static site never updates itself.