MirrorNest
← すべてのガイド

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.

対象: Ubuntu 22.04 LTS / 24.04 LTSstatic-site-generatorNginxMarkdown公式ホームページ ↗公式ドキュメント ↗
このガイドは上記リンク先にあるHugo static site with Nginx公式ドキュメントをもとに作成されています。ディストリビューションやプロジェクトのバージョンは時間とともに変わるため、本番サーバーでこれらのコマンドを実行する前に、必ず公式ドキュメントで正確なパッケージ名・バージョン名を確認してください。
  1. 1Install Hugo

    sudo apt update
    sudo apt install -y hugo
  2. 2Create 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 mysite
    cd mysite
    git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
    echo "theme = 'ananke'" >> hugo.toml
    hugo
  3. 3Serve 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 nginx
    sudo 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.