Skip to content

This is the multi-page printable view of this section.

Return to the regular view of this page

Get started

Clone the OINK docs site to run a full site locally in two minutes, then build your own personal or project site with an AI agent, from scratch, or inside a project’s docs/ folder.

The fastest way to understand OINK is to clone this documentation site and run it on your machine. In two minutes you have a complete live site to click through—with real Markdown source right beside it—and from there you can hand one prompt to an AI coding agent to build your own site.

Prerequisites

You need Git, Go, and Hugo (tested on 0.170+). Go is required because Hugo fetches the theme as a Go module; building an OINK site never needs Node.js, npm or a Sass compiler.

$ hugo version
hugo v0.170.1+withdeploy darwin/arm64

On macOS, brew install git go hugo installs all three. On Linux and Windows, follow the Hugo installation guide and the Go downloads page.

Step 1: Clone the docs site and run it locally

Instead of staring at an empty skeleton, clone oink.pgsty.com itself and start Hugo’s local server:

Terminal
git clone https://github.com/pgsty/oink.pgsty.com.git
cd oink.pgsty.com
hugo serve

The first run takes a moment while Hugo downloads the pinned OINK theme into your local Go module cache; every subsequent start takes a second. Open http://localhost:1313/ to explore the live site:

  • Click through Docs, Book, Case and Blog, and open the Appearance menu to switch between Paper, Slate, GitHub, Ink, News and Terminal in both light and dark mode.
  • Press / to try local full-text search, and switch between English and Chinese from the top bar.
  • Open any page under content/docs/components/ in your editor, change a sentence, and save: the browser reloads automatically so you can see how Markdown maps to rendered components.

Because this repository doubles as OINK’s integration test suite, treat it as a live reference rather than a template to deploy. Once you know what you want, create your own site in a fresh directory below.

Step 2: Build your own site with an AI agent

Once Git, Go and Hugo work on your machine, the fastest way to build your own site is to open a coding agent such as Claude Code or Codex in an empty folder and give it a concrete prompt backed by the OINK site-building skill (oink-site):

Terminal
mkdir my-site && cd my-site
claude   # or codex, or any coding agent that runs shell commands

Paste this prompt after replacing the <angle brackets> with your own details:

Prompt: build a personal site with Hugo and OINK
Read https://oink.pgsty.com/skill.md and follow it to build my personal site
with Hugo and the OINK theme in this empty directory.

About me: <Your Name>, <one-line bio, e.g. backend engineer writing about
databases and distributed systems>.
Domain: <https://you.example.com>.
Languages: <English, or English and Simplified Chinese>.

Site structure:
- Home page assembled from OINK landing data: a concise hero introducing me,
  cards linking to my main sections, and links to GitHub / X.
- A Blog section with card-grid indexes, tags, RSS feed, and three realistic
  starter posts in my voice.
- A Notes section using the Docs shell for evergreen technical notes.
- An About page with my bio, current projects, and contact links.

Appearance and hygiene:
- Default to the Paper preset, enable dark mode, and offer Paper, Slate,
  GitHub, Ink, News and Terminal in the Appearance menu.
- Enable local search, Markdown outputs, and llms.txt; include a .gitignore
  that excludes public/, resources/, .hugo_build.lock and .hugo_cache/.
- Pin the latest published OINK release in go.mod rather than tracking main.

When the production build passes with zero unexpected warnings, run hugo serve,
check the site in a browser on desktop and mobile widths, and tell me what
placeholders I should replace next.

The skill file (https://oink.pgsty.com/skill.md, or https://oink.pgsty.com/skill.zh.md for Simplified Chinese) sends the agent to these docs for current OINK syntax, warns it away from retired Docsy or older OINK keys, and maps each kind of site to real examples in the case library.

To keep the skill installed across sessions instead of referencing its URL each time, download it once and start a new agent session:

Claude Code
mkdir -p ~/.claude/skills/oink-site
curl -fsSL https://oink.pgsty.com/skill.md -o ~/.claude/skills/oink-site/SKILL.md
Codex
mkdir -p ~/.codex/skills/oink-site
curl -fsSL https://oink.pgsty.com/skill.md -o ~/.codex/skills/oink-site/SKILL.md

Download the file again whenever you want to refresh it; the header notes the OINK release it targets. For more prompt patterns—open-source project sites, CLI manuals and books—read Build a site from one prompt.

Choose your next guide

From here, follow the guide that matches where your site lives today:

  • Browse locally — Already have an OINK repository? Run hugo serve, read live docs in the browser, edit with auto-reload, and monitor reports written by coding agents.
  • From scratch — Assemble a minimal standalone site file by file, or switch an existing Hugo site to OINK: project layout, hugo.yml prerequisites, first page, and offline or submodule installs.
  • Add docs to a project — Already have an open-source codebase? Add an isolated docs/ Hugo sub-project with .gitignore hygiene and GitHub Pages or Cloudflare Pages auto-builds.
  • Upgrade — Upgrading an older OINK site or migrating from Docsy: version upgrades, syntax migration, and override review.

1 - Browse locally

Clone an existing OINK repository and run hugo serve to read docs in your browser, preview edits as you type, and watch AI agents’ latest reports render live.

You do not need to deploy a site—or even build one yourself—to get value from OINK. Whenever you have an OINK repository on disk (this docs site, a teammate’s handbook, an online book, or a workspace where an AI agent writes notes), running hugo serve turns that folder into a fast, searchable local website in your browser.

Clone and start the server

Install Git, Go and Hugo per Prerequisites, then clone the repository and run hugo serve (Hugo’s short alias for hugo server) in the folder that holds hugo.yml or hugo.yaml:

Terminal
git clone https://github.com/OWNER/OINK-SITE.git
cd OINK-SITE
hugo serve

The first start downloads the pinned OINK theme into your local Go module cache. Once the terminal prints Web Server is available at http://localhost:1313/, open http://localhost:1313/ in any browser. Press Ctrl with C in the terminal whenever you want to stop the server.

Read in the browser, not raw Markdown

Reading a documentation tree through hugo serve gives you the full reading experience that plain Markdown viewers cannot render:

  • Structured navigation: the collapsible sidebar, page outline (TOC), breadcrumbs, and previous/next links stay in sync with the folder tree.
  • Instant search and shortcuts: press / or Ctrl with K to search the whole repository locally, and press ' or click the footer ? button to view keyboard shortcuts.
  • Rendered components: callouts, tabs, field tables, KaTeX math, Mermaid and ECharts diagrams, and galleries render natively with no network dependencies. Maps render their place list offline too; map tiles load only when the site has configured a tile service.
  • Reader comfort: switch between Paper, Slate, GitHub, Ink, News and Terminal, toggle light and dark mode, open Duo View on bilingual sites, or print clean PDFs.

If the repository includes unpublished drafts (draft: true in front matter), start the server with hugo serve -D so those pages appear in the sidebar too.

Edit and watch changes reload live

Leave hugo serve running in one terminal while you edit Markdown files under content/ or home-page YAML under data/. Every time you save a file—or switch Git branches—Hugo rebuilds the affected pages in milliseconds and refreshes your browser tab automatically.

Useful daily preview commands
hugo serve -D                     # include draft pages while writing
hugo serve -D --navigateToChanged # jump the browser straight to the file you just saved
hugo serve -D --renderToMemory    # serve from memory without writing anything to public/

Passing --renderToMemory (-M) is especially clean when you are reviewing a repository in Git, because the preview never touches public/ on disk.

Follow AI agent reports in real time

When a coding agent such as Claude Code or Codex is working on a large task—for example, auditing a codebase, writing design proposals, drafting documentation, or logging experiment results—reading long Markdown tables and diagrams inside a scrolling terminal quickly becomes tiring.

Point the agent to write its reports as ordinary Markdown pages inside an OINK site’s content/ directory, and keep hugo serve -D --renderToMemory running in a side terminal with http://localhost:1313/ open in your browser:

  1. The agent writes or updates a report (such as content/docs/reports/audit.md) with headings, {.fields} tables, callouts, or Mermaid / ECharts diagrams.
  2. Hugo detects the file write immediately, rebuilds in memory, and reloads the browser tab while keeping your reading position.
  3. You read formatted sections, interactive diagrams, and cross-linked pages in real time—and because --renderToMemory writes no build output to disk, the agent’s Git working tree stays clean.

This turns any OINK repository into a zero-setup local reading room for both human notes and agent-generated reports.

Common snags

Symptom Fix
Port 1313 is already in use by another preview Run hugo serve -p 1314 to pick another port
A change to hugo.yml, data/, or a layout did not appear Restart with hugo serve --disableFastRender, then hard-reload the browser
A page with draft: true is missing from the sidebar Add -D (hugo serve -D)
The site lives inside a docs/ subfolder of a larger repo Run hugo serve -s docs from the repository root, or cd docs && hugo serve

For advanced server switches, phone/LAN preview, Docker containers, cache clearing, and production builds, see Local preview.

2 - From scratch

See what a minimal standalone OINK project looks like, build one from an empty directory, add OINK to an existing Hugo site, or install it without Go modules.

When you want a clean standalone OINK site and want to understand every file in it—rather than letting an agent scaffold it or cloning a large template—a working project takes only a handful of files. This guide walks from an empty folder to a live site, shows how to switch an existing Hugo site to OINK, and covers offline and non-Go install methods.

If you want to add documentation inside an existing code repository’s docs/ directory instead of creating a separate repository, read Add docs to a project. If you prefer a pre-built three-language Docs, Blog and Book template with GitHub Pages and Cloudflare Pages workflows ready to edit, you can also start from the OINK Starter. For Docsy sites, follow Migrating from Docsy.

What a minimal OINK project looks like

An OINK site is an ordinary Hugo repository. The theme itself does not live in your Git tree: go.mod pins the exact OINK tag, and Hugo downloads it into the module cache on the first build.

my-docs/

  • my-docs/
    • hugo.ymlsingle site config: title, baseURL, languages, Goldmark, params, theme import
    • go.modpins github.com/pgsty/oink@vX.Y.Z
    • go.sumchecksums that verify the pinned release
    • .gitignorekeeps public/, resources/ and Hugo caches out of Git
    • content/
      • _index.mdhome page entry (optional when data/home/ drives the home page)
      • docs/
        • _index.mdDocs section root: title, weight, sidebar root
        • install.mdyour first documentation page
    • data/
      • home/
        • en.yamloptional data-driven landing page (one file per language)
    • assets/
      • icons/logo.svgoptional navbar logo, processed by Hugo
      • css/project.cssoptional plain-CSS overrides (no Sass needed)
    • static/
      • favicon.svgoptional browser icon, copied unchanged

Everything else—stylesheets, scripts, fonts, Font Awesome icons, search, diagrams, and layouts—comes from the theme module. Commit source files plus go.mod and go.sum; keep public/, resources/, .hugo_build.lock and .hugo_cache/ ignored.

From an empty directory to the first page

Make sure Git, Go and Hugo are installed per Prerequisites, then run these four steps.

  1. Create the skeleton and fetch the theme

    Terminal
    hugo new site --format yaml my-docs
    cd my-docs
    git init
    hugo mod init github.com/example/my-docs
    hugo mod get github.com/pgsty/oink@v1.8.0

    Replace github.com/example/my-docs with your repository’s module path. hugo mod get creates go.mod and go.sum; commit both so every machine and CI run builds against the exact same verified theme release. Pin a tag rather than main so the site changes only when you deliberately upgrade; GitHub Releases lists every tag.

    Create .gitignore before your first build so generated artifacts never enter Git:

    .gitignore
    /public/
    /resources/
    /.hugo_build.lock
    /.hugo_cache/
    go.work
    go.work.sum
  2. Write hugo.yml

    Rename the generated hugo.yaml to hugo.yml (Hugo accepts either name; keep only one configuration file at the root) and replace its contents with the baseline below:

    hugo.yml
    title: Product Docs
    baseURL: https://docs.example.com/
    defaultContentLanguage: en
    # enableGitInfo: true # enable after your first Git commit so pages show last-modified dates
    
    languages:
      en:
        label: English
        locale: en-US
        weight: 1
        title: Product Docs
        params:
          description: Everything about running Product in production
        menus:
          main:
            - { name: Docs, pageRef: /docs, weight: 20 }
            - { name: Blog, pageRef: /blog, weight: 50 }
    
    # The three Goldmark prerequisites: OINK's Markdown components depend on them
    markup:
      goldmark:
        renderer:
          unsafe: true # allow inline HTML in content
        parser:
          attribute:
            block: true # attribute lines such as {.steps} {.cards} {caption=}
          wrapStandAloneImageWithinParagraph: false # block images carry attribute lines
      highlight:
        noClasses: false # code colors follow light and dark mode
    
    params:
      offline_search: true
      github_repo: https://github.com/example/my-docs
      copyright:
        authors: '[Example Inc.](https://example.com/)'
        from_year: 2026
      ui:
        preset: paper
        preset_menu: [paper, slate, github, ink, news, terminal]
        dark_mode: true
        sidebar_menu_foldable: true
        section_index: cards
    
    outputs:
      home: [HTML, markdown, LLMS]
      page: [HTML, markdown]
      section: [HTML, RSS, print, markdown]
    
    module:
      imports:
        - path: github.com/pgsty/oink

    Each block has one job:

    Block Controls Without it
    Top level + languages Site name, canonical baseURL, languages and navbar A wrong baseURL breaks absolute links and search in production
    markup.goldmark The three parser settings OINK components need Attribute lines render as literal {.steps} text
    params Local search, repository links, presets and shell switches Optional features stay off by design
    outputs Per-page .md copies, llms.txt and print views No “Copy as Markdown” or print view
    module Theme import Hugo cannot locate OINK

    For math equations, also add Goldmark’s passthrough extension from Math. Every site parameter and its default lives in Configuration.

  3. Write the first section and page

    Each top-level directory under content/ becomes a section, and nested folders build the sidebar ordered by weight. Give the section an _index.md and add your first page:

    content/docs/_index.md
    ---
    title: Docs
    linkTitle: Docs
    description: Everything about running Product in production.
    weight: 20
    ---
    
    Start with [Install](/docs/install/).
    content/docs/install.md
    ---
    title: Install
    description: Install Product on a fresh machine.
    weight: 10
    ---
    
    ## Prerequisites {#prerequisites}
    
    > [!IMPORTANT]
    > Product requires PostgreSQL 18 or newer.
    
    ## Install {#install}
    
    ```bash
    curl -fsSL https://get.example.com | bash
    ```

    Add explicit {#id} anchors to headings from day one: if you add a second language later, both languages share identical section links. See Writing pages and Organizing content for the full authoring model.

  4. Preview locally

    Terminal
    hugo serve

    Open http://localhost:1313/docs/. You should see the Docs sidebar listing Install, working search, and the appearance switcher. The site root stays minimal until you add a landing page in data/home/; see Home and landing pages.

Add OINK to an existing Hugo site

If you already have a Hugo site with content, work on a Git branch and keep your existing content/ tree intact; you do not need hugo new site:

  1. If the site lacks go.mod, run hugo mod init with your repository’s module path; if it already has one, keep it.
  2. Run hugo mod get github.com/pgsty/oink@v1.8.0.
  3. Replace the old theme selection in your configuration with module.imports pointing to github.com/pgsty/oink (keeping unrelated module imports), and merge the three markup.goldmark settings plus markup.highlight.noClasses: false from Write hugo.yml.
  4. Review custom templates under layouts/, stylesheets under assets/, old-theme shortcodes, and front-matter type or layout values that depended on the previous theme.
  5. Run hugo serve, check representative pages across light and dark modes, then turn on optional OINK features one by one and finish with Verify.

Other install methods

A Hugo Module is the default because Hugo resolves the version and verifies its checksum in go.sum. The other three methods serve specific constraints: an isolated network without Go proxy access, a host without Go installed, or an organization that audits a vendored copy inside its repository. Apart from hugo mod vendor, they replace module.imports with theme: oink, making version tracking and integrity checks your responsibility.

The four methods compared

Method Needs Go Version auditable Theme source in your repo Use when
Hugo Module Yes go.sum verifies automatically No The default
Git submodule No Repository records the commit By reference Theme must be referenced inside Git without Go
Offline archive No Checksums verified by hand Yes Air-gapped or offline build environments
Pinned source copy No Record the tag and checksum Yes Host requires a complete committed tree

Hugo Module (recommended)

Terminal
hugo mod init github.com/example/product-docs
hugo mod get github.com/pgsty/oink@v1.8.0
hugo.yml
module:
  imports:
    - path: github.com/pgsty/oink

Run hugo mod graph to verify the resolved version and hugo mod get -u to upgrade. Every machine that builds the site needs Go.

Git submodule

The site repository pins an exact theme commit:

Terminal
git submodule add https://github.com/pgsty/oink.git themes/oink
git -C themes/oink fetch --tags
git -C themes/oink checkout v1.8.0
git add .gitmodules themes/oink
hugo.yml
theme: oink

CI must initialize submodules before running Hugo, otherwise themes/oink is empty:

CI checkout step
git submodule update --init --recursive

Offline archive

For an isolated network without internet access, prepare the theme on a connected machine and move the complete package across. There are two routes.

hugo mod vendor freezes the resolved module into _vendor/, so later builds need neither network access nor Go:

Terminal
hugo mod vendor          # writes _vendor/ with the theme's mounted tree
tar czf ../my-docs.tgz . # place the archive outside the directory being packed

Whenever _vendor/ exists, Hugo reads it automatically (hugo mod graph shows +vendor) and module.imports stays unchanged. Only the vendoring step needs Go; to upgrade, re-run hugo mod get and hugo mod vendor on a connected machine. Because _vendor/ omits LICENSE, NOTICE and VENDOR.json, copy those three files from the theme repository if you redistribute the archive.

A release tag archive avoids Go modules completely. Download a tagged archive and unpack it into themes/oink/:

Terminal
curl -L -o oink.tar.gz \
  https://github.com/pgsty/oink/archive/refs/tags/v1.8.0.tar.gz
mkdir -p themes/oink
tar xzf oink.tar.gz -C themes/oink --strip-components=1
hugo.yml
theme: oink

Because the repository root is the theme root, layouts/, assets/, i18n/ and static/ unpack straight under themes/oink/. To transfer the archive with a checksum, create both on the connected machine:

Connected machine
git clone --branch v1.8.0 --depth 1 \
  https://github.com/pgsty/oink.git oink
git -C oink archive --format=tar.gz --prefix=oink/ \
  --output=../oink-v1.8.0.tar.gz v1.8.0
shasum -a 256 oink-v1.8.0.tar.gz \
  > oink-v1.8.0.tar.gz.sha256

Verify and unpack on the isolated machine:

Isolated machine
shasum -a 256 -c oink-v1.8.0.tar.gz.sha256
mkdir -p themes
tar -xzf oink-v1.8.0.tar.gz -C themes

Confirm these eleven top-level entries exist before your first offline build, and keep LICENSE, NOTICE and VENDOR.json when redistributing:

themes/oink/

  • oink/
    • go.modmodule path declaration
    • hugo.yamltheme default parameters and mounts
    • theme.tomltheme metadata required by theme: oink
    • LICENSEApache-2.0
    • NOTICEupstream attribution
    • VENDOR.jsonthird-party runtime manifest: version, source, license, SHA-256
    • assets/stylesheets, JS and bundled third-party runtimes
    • layouts/templates, partials, shortcodes, render hooks
    • static/bundled font files
    • i18n/32 interface language catalogs
    • data/SPDX license table for page-end attribution

Bootstrap, Font Awesome, fonts, search, and diagram runtimes all ship inside the theme, so an offline deployment needs no node_modules, PostCSS or CDN.

Pinned source copy

If your host requires theme source files inside the site repository, unpack a verified tag archive into themes/oink/ as above, set theme: oink, and commit the files alongside a note of the tag and SHA-256 checksum.

Do not run git clone into themes/oink and commit that folder: the nested .git directory makes Git record an uninitialized gitlink instead of the files. To track by reference, use a Git submodule.

Developing against a local theme checkout

Only needed when editing the OINK theme and a site together. Place both checkouts side by side:

Sibling directory layout
~/pgsty/
├── oink/            # the theme
└── product-docs/    # your site

Point Hugo at the sibling checkout for a single command without touching go.mod:

Terminal
cd ~/pgsty/product-docs
HUGO_MODULE_REPLACEMENTS='github.com/pgsty/oink -> ../oink' hugo serve

A Go workspace (go work init with HUGO_MODULE_WORKSPACE=go.work) works the same way. Neither should ever enter Git; CI must build the release pinned in go.mod. See Previewing against a theme checkout for verifying which theme release actually resolved.

Verify

Terminal
hugo mod graph                                                  # confirm the resolved OINK tag
hugo --cleanDestinationDir --gc --minify --printPathWarnings

The build succeeds when it finishes with Total in … and prints no unexpected warnings. Check that /docs/ opens with your sidebar, search finds a heading from your page, dark mode changes code-block colors (noClasses: false), and git status --short lists only source files (hugo.yml, go.mod, go.sum, content/).

  • Get started — run the docs site locally and try the AI agent prompt
  • Browse locally — daily reading, live editing, and watching AI agent reports
  • Add docs to a project — embed an OINK site inside a repo’s docs/ directory
  • Configuration — every hugo.yml key and default
  • Deploy — publishing public/ to GitHub Pages, Cloudflare Pages, or your own host
  • Upgrade — upgrading OINK releases and migrating from Docsy

3 - Add docs to a project

Add a self-contained OINK documentation site inside an existing open-source repository’s docs/ directory, keep build outputs out of Git, and wire GitHub Pages and Cloudflare Pages auto-builds.

You already have an open-source repository with application code—a Go service, a Rust CLI, a Python package, or a database extension—and you want real documentation to live right beside the code so pull requests update code and docs together. Putting a self-contained OINK site inside docs/ keeps Hugo isolated from your main build while publishing cleanly on every push.

For a real production example of this layout, see AGW, which hosts its bilingual documentation and landing page inside a subfolder of its application repository.

Repository layout

Keep the Hugo configuration, module pin, and content completely inside docs/:

my-project/

  • my-project/
    • cmd/your project's own source code
    • internal/
    • go.modyour project's own Go module (if it is a Go project)
    • README.md
    • .gitignoreexcludes docs/ build outputs without hiding app files
    • .github/
      • workflows/
        • ci.yamlexisting application tests
        • docs.yamlbuilds and deploys docs/ only when docs/ changes
    • docs/self-contained OINK sub-project
      • hugo.ymlsite config with github_subdir: docs
      • go.modpins github.com/pgsty/oink@vX.Y.Z
      • go.sumverifies the pinned OINK release
      • content/
        • _index.md
        • docs/
          • _index.md
          • install.md
      • data/
        • home/
          • en.yaml
      • assets/
        • icons/logo.svg
      • static/
        • favicon.svg

Giving docs/ its own go.mod is deliberate: even if your project itself is written in Go and already has a go.mod at the repository root, the two module graphs stay completely separate so the documentation theme never enters your application’s dependency tree.

Initialize the docs/ sub-project

Install Git, Go and Hugo per Prerequisites, then run these steps from your project’s repository root:

  1. Create docs/ and pin OINK

    Terminal
    mkdir -p docs/content/docs
    cd docs
    hugo mod init github.com/OWNER/PROJECT/docs
    hugo mod get github.com/pgsty/oink@v1.8.0

    Ending the module path in /docs keeps it distinct from the root module. Commit both docs/go.mod and docs/go.sum so CI resolves the exact same theme tag you tested locally.

  2. Write docs/hugo.yml with github_subdir

    Create docs/hugo.yml. Compared to a standalone site, the crucial extra setting is params.github_subdir: docs: without it, every Edit this page and history link points to /content/... at the repository root and returns 404 on GitHub.

    docs/hugo.yml
    title: My Project
    baseURL: https://OWNER.github.io/PROJECT/
    defaultContentLanguage: en
    enableGitInfo: true
    
    languages:
      en:
        label: English
        locale: en-US
        weight: 1
        title: My Project
        params:
          description: Documentation for My Project
        menus:
          main:
            - { name: Docs, pageRef: /docs, weight: 20 }
    
    markup:
      goldmark:
        renderer:
          unsafe: true
        parser:
          attribute:
            block: true
          wrapStandAloneImageWithinParagraph: false
      highlight:
        noClasses: false
    
    params:
      offline_search: true
      github_repo: https://github.com/OWNER/PROJECT
      github_branch: main
      github_subdir: docs # required when the Hugo site lives in docs/
      ui:
        preset: paper
        preset_menu: [paper, slate, github, ink, news, terminal]
        dark_mode: true
        sidebar_menu_foldable: true
        section_index: cards
    
    outputs:
      home: [HTML, markdown, LLMS]
      page: [HTML, markdown]
      section: [HTML, RSS, print, markdown]
    
    module:
      imports:
        - path: github.com/pgsty/oink
  3. Add your first page and preview

    Write docs/content/docs/_index.md and docs/content/docs/install.md (see From scratch for minimal examples), then preview from the repository root with -s docs (or cd docs && hugo serve):

    Terminal (from repository root)
    hugo serve -s docs

    Open http://localhost:1313/docs/ and verify that the Edit this page entry in the page-actions menu beside the title opens docs/content/docs/... in your repository.

Manage .gitignore cleanly

Hugo writes generated HTML, processed images, lock files and module caches into the site directory. Add explicit docs/-prefixed ignore rules to your repository’s .gitignore before running your first build, so generated output never bloats Git history or creates merge conflicts—and so you never accidentally ignore a public/ or resources/ directory used by your main application:

.gitignore (repository root)
# OINK / Hugo documentation build outputs and local caches
docs/public/
docs/resources/
docs/.hugo_build.lock
docs/.hugo_cache/
go.work
go.work.sum

Know which files stay out of Git and which ones CI requires:

Path Track in Git? Why
docs/public/ Ignore Built HTML/CSS/JS output; regenerated cleanly by CI on every deploy
docs/resources/ Ignore Cached processed images (_gen/); stale copies bloat diffs
docs/.hugo_build.lock Ignore Ephemeral Hugo build lock file
docs/.hugo_cache/ Ignore Local or CI Hugo cache directory
go.work, go.work.sum Ignore Machine-local Go workspace paths break other contributors and CI
docs/hugo.yml, docs/go.mod, docs/go.sum Commit Site configuration and exact checksum-verified OINK release
docs/content/, docs/data/, docs/assets/, docs/static/ Commit Authored Markdown, landing data, logos, CSS and static files

Run a production build once and check git status --short to verify that zero generated files show up as untracked:

Terminal
hugo -s docs --cleanDestinationDir --gc --minify --environment production --printPathWarnings
git status --short

Auto-build on GitHub Pages

Add one GitHub Actions workflow at .github/workflows/docs.yaml. Two details differ from a standalone docs repository: every build step runs inside working-directory: docs (with cache-dependency-path: docs/go.sum and artifact path docs/public), and the paths: filter ensures code-only commits do not waste runner minutes rebuilding unchanged docs.

.github/workflows/docs.yaml
 1name: Deploy Docs to GitHub Pages
 2
 3on:
 4  push:
 5    branches: [main]
 6    paths:
 7      - 'docs/**'
 8      - '.github/workflows/docs.yaml'
 9  workflow_dispatch:
10
11permissions:
12  contents: read
13  pages: write
14  id-token: write
15
16concurrency:
17  group: github-pages
18  cancel-in-progress: false
19
20env:
21  # Never let a workspace override the release pinned in docs/go.mod.
22  GOWORK: off
23  HUGO_MODULE_WORKSPACE: off
24  HUGO_CACHEDIR: ${{ github.workspace }}/docs/.hugo_cache
25
26jobs:
27  build:
28    name: Build docs
29    runs-on: ubuntu-latest
30    defaults:
31      run:
32        working-directory: docs
33    steps:
34      - name: Check out repository
35        uses: actions/checkout@v7
36        with:
37          fetch-depth: 0 # required for enableGitInfo last-modified dates
38
39      - name: Set up Go
40        uses: actions/setup-go@v7
41        with:
42          go-version: stable
43          cache-dependency-path: docs/go.sum
44
45      - name: Configure GitHub Pages
46        id: pages
47        uses: actions/configure-pages@v6
48
49      - name: Install Hugo
50        uses: peaceiris/actions-hugo@v3
51        with:
52          hugo-version: latest
53
54      - name: Download OINK module
55        run: go mod download github.com/pgsty/oink
56
57      - name: Build production site
58        run: |
59          hugo --cleanDestinationDir --gc --minify --environment production \
60            --printPathWarnings \
61            --baseURL "${{ steps.pages.outputs.base_url }}/"
62
63      - name: Upload Pages artifact
64        uses: actions/upload-pages-artifact@v5
65        with:
66          path: docs/public
67
68  deploy:
69    name: Deploy
70    environment:
71      name: github-pages
72      url: ${{ steps.deployment.outputs.page_url }}
73    runs-on: ubuntu-latest
74    needs: build
75    steps:
76      - name: Publish
77        id: deployment
78        uses: actions/deploy-pages@v5

How the build logic hangs together:

  • paths: ['docs/**', '.github/workflows/docs.yaml'] triggers automatic deploys only when documentation or the workflow itself changes; workflow_dispatch still lets you trigger a deploy manually at any time.
  • defaults.run.working-directory: docs makes go mod download and hugo operate strictly on docs/go.mod and docs/hugo.yml without touching a root-level go.mod.
  • --baseURL "${{ steps.pages.outputs.base_url }}/" injects the exact URL GitHub Pages serves—including the /<PROJECT>/ subpath—so search indexes, stylesheets and canonical links never 404.
  • --printPathWarnings without --panicOnWarning keeps OINK’s warnings readable in the log without aborting on non-fatal diagnostics.

In GitHub, open Settings → Pages → Build and deployment → Source, choose GitHub Actions, and push to main.

Auto-build on Cloudflare Pages

Cloudflare Pages supports two deployment models for a docs/ sub-project. Pick one per Cloudflare Pages project—never connect both Git integration and Direct Upload to the same project:

Building in GitHub Actions and uploading docs/public via Wrangler lets you run the latest Hugo release (even when Cloudflare’s default build image ships an older Hugo), plus native paths: filtering so application-only pushes skip doc deploys.

.github/workflows/docs-cloudflare.yaml
 1name: Deploy Docs to Cloudflare Pages
 2
 3on:
 4  push:
 5    branches: [main]
 6    paths:
 7      - 'docs/**'
 8      - '.github/workflows/docs-cloudflare.yaml'
 9  workflow_dispatch:
10
11permissions:
12  contents: read
13  deployments: write
14
15concurrency:
16  group: cloudflare-docs-${{ github.ref }}
17  cancel-in-progress: true
18
19env:
20  GOWORK: off
21  HUGO_MODULE_WORKSPACE: off
22  HUGO_CACHEDIR: ${{ github.workspace }}/docs/.hugo_cache
23
24jobs:
25  deploy:
26    name: Build and upload docs
27    runs-on: ubuntu-latest
28    defaults:
29      run:
30        working-directory: docs
31    steps:
32      - name: Check out repository
33        uses: actions/checkout@v7
34        with:
35          fetch-depth: 0
36
37      - name: Set up Go
38        uses: actions/setup-go@v7
39        with:
40          go-version: stable
41          cache-dependency-path: docs/go.sum
42
43      - name: Install Hugo
44        uses: peaceiris/actions-hugo@v3
45        with:
46          hugo-version: latest
47
48      - name: Download OINK module
49        run: go mod download github.com/pgsty/oink
50
51      - name: Build production site
52        env:
53          SITE_URL: ${{ vars.CLOUDFLARE_SITE_URL || 'https://my-project.pages.dev/' }}
54        run: |
55          hugo --cleanDestinationDir --gc --minify --environment production \
56            --printPathWarnings \
57            --baseURL "${SITE_URL}"
58
59      - name: Upload to Cloudflare Pages
60        uses: cloudflare/wrangler-action@v4
61        with:
62          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
63          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
64          command: pages deploy docs/public --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME || github.event.repository.name }} --branch=${{ github.ref_name }}
65          gitHubToken: ${{ secrets.GITHUB_TOKEN }}

Set up Cloudflare once:

  1. In the Cloudflare dashboard, create a Direct Upload Pages project.
  2. Add repository secrets CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (scoped to Account → Cloudflare Pages → Edit).
  3. Set optional repository variables CLOUDFLARE_PROJECT_NAME (defaults to the repository name) and CLOUDFLARE_SITE_URL once you attach a custom domain such as https://docs.example.com/.

If you prefer Cloudflare to run Hugo directly with no GitHub Actions workflow, connect the repository in Workers & Pages → Create → Pages → Connect to Git and configure these build settings:

Setting Value Why
Root directory (path) docs Runs hugo inside docs/ so it reads docs/hugo.yml and docs/go.mod
Build command hugo --cleanDestinationDir --gc --minify --environment production --printPathWarnings Matches OINK’s production build flags
Build output directory public Relative to Root directory (docs), publishing docs/public
Include watch paths docs/* Skips doc builds on commits that only touch application source code
HUGO_VERSION 0.170.1 (or current release) Overrides Cloudflare’s older default Hugo (OINK is tested on 0.170+)
GOWORK / HUGO_MODULE_WORKSPACE off Prevents workspaces from overriding docs/go.mod

For branch preview builds, override the preview build command with --environment staging --baseURL "$CF_PAGES_URL" so Cloudflare preview URLs emit noindex and never compete with your production domain in search engines.

Verify before you merge

  1. Run hugo -s docs --cleanDestinationDir --gc --minify --environment production --printPathWarnings and confirm the log ends with Total in … and no unexpected warnings.
  2. Run git status --short: docs/public/, docs/resources/ and docs/.hugo_build.lock must not appear.
  3. Commit docs/hugo.yml, docs/go.mod, docs/go.sum, docs/content/, .gitignore and your workflow file.
  4. After the workflow turns green, open the live URL and check search, dark mode, canonical links, and Edit this page (it must open the file under docs/content/).
  • Deploy — custom domains, baseURL, CSP headers, preview indexing, and rollback
  • Browse locally — run hugo serve -s docs while writing code and docs side by side
  • From scratch — standalone OINK setup and offline / submodule install methods
  • Configuration — full hugo.yml reference, including github_subdir