This is the multi-page printable view of this section.
Get started
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.
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:
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):
Paste this prompt after replacing the <angle brackets> with your own details:
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:
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.ymlprerequisites, 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.gitignorehygiene 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
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:
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.
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:
- The agent writes or updates a report (such as
content/docs/reports/audit.md) with headings,{.fields}tables, callouts, or Mermaid / ECharts diagrams. - Hugo detects the file write immediately, rebuilds in memory, and reloads the browser tab while keeping your reading position.
- You read formatted sections, interactive diagrams, and cross-linked pages in
real time—and because
--renderToMemorywrites 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.
Related
- Get started — clone the docs site and try building with an AI agent
- From scratch — build your own standalone OINK site
- Add docs to a project — add a
docs/site to an existing repository - Local preview — full
hugo serverreference, LAN access, containers, and caches
2 - From scratch
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)
- home/
- 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.
-
Create the skeleton and fetch the theme
TerminalReplace
github.com/example/my-docswith your repository’s module path.hugo mod getcreatesgo.modandgo.sum; commit both so every machine and CI run builds against the exact same verified theme release. Pin a tag rather thanmainso the site changes only when you deliberately upgrade; GitHub Releases lists every tag.Create
.gitignorebefore your first build so generated artifacts never enter Git:.gitignore -
Write
hugo.ymlRename the generated
hugo.yamltohugo.yml(Hugo accepts either name; keep only one configuration file at the root) and replace its contents with the baseline below:hugo.ymlEach block has one job:
Block Controls Without it Top level + languagesSite name, canonical baseURL, languages and navbarA wrong baseURLbreaks absolute links and search in productionmarkup.goldmarkThe three parser settings OINK components need Attribute lines render as literal {.steps}textparamsLocal search, repository links, presets and shell switches Optional features stay off by design outputsPer-page .mdcopies,llms.txtand print viewsNo “Copy as Markdown” or print view moduleTheme 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.
-
Write the first section and page
Each top-level directory under
content/becomes a section, and nested folders build the sidebar ordered byweight. Give the section an_index.mdand add your first page:content/docs/_index.mdcontent/docs/install.mdAdd 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. -
Preview locally
TerminalOpen 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:
- If the site lacks
go.mod, runhugo mod initwith your repository’s module path; if it already has one, keep it. - Run
hugo mod get github.com/pgsty/oink@v1.8.0. - Replace the old theme selection in your configuration with
module.importspointing togithub.com/pgsty/oink(keeping unrelated module imports), and merge the threemarkup.goldmarksettings plusmarkup.highlight.noClasses: falsefrom Writehugo.yml. - Review custom templates under
layouts/, stylesheets underassets/, old-theme shortcodes, and front-mattertypeorlayoutvalues that depended on the previous theme. - 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)
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:
CI must initialize submodules before running Hugo, otherwise themes/oink is
empty:
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:
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/:
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:
Verify and unpack on the isolated machine:
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:
Point Hugo at the sibling checkout for a single command without touching
go.mod:
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
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/).
Related
- 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.ymlkey 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
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
- workflows/
- 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
- home/
- 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:
-
Create
docs/and pin OINKTerminalEnding the module path in
/docskeeps it distinct from the root module. Commit bothdocs/go.modanddocs/go.sumso CI resolves the exact same theme tag you tested locally. -
Write
docs/hugo.ymlwithgithub_subdirCreate
docs/hugo.yml. Compared to a standalone site, the crucial extra setting isparams.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 -
Add your first page and preview
Write
docs/content/docs/_index.mdanddocs/content/docs/install.md(see From scratch for minimal examples), then preview from the repository root with-s docs(orcd docs && hugo serve):Terminal (from repository root)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:
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:
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.
How the build logic hangs together:
paths: ['docs/**', '.github/workflows/docs.yaml']triggers automatic deploys only when documentation or the workflow itself changes;workflow_dispatchstill lets you trigger a deploy manually at any time.defaults.run.working-directory: docsmakesgo mod downloadandhugooperate strictly ondocs/go.modanddocs/hugo.ymlwithout touching a root-levelgo.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.--printPathWarningswithout--panicOnWarningkeeps 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.
Set up Cloudflare once:
- In the Cloudflare dashboard, create a Direct Upload Pages project.
- Add repository secrets
CLOUDFLARE_ACCOUNT_IDandCLOUDFLARE_API_TOKEN(scoped to Account → Cloudflare Pages → Edit). - Set optional repository variables
CLOUDFLARE_PROJECT_NAME(defaults to the repository name) andCLOUDFLARE_SITE_URLonce you attach a custom domain such ashttps://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
- Run
hugo -s docs --cleanDestinationDir --gc --minify --environment production --printPathWarningsand confirm the log ends withTotal in …and no unexpected warnings. - Run
git status --short:docs/public/,docs/resources/anddocs/.hugo_build.lockmust not appear. - Commit
docs/hugo.yml,docs/go.mod,docs/go.sum,docs/content/,.gitignoreand your workflow file. - 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/).
Related
- Deploy — custom domains,
baseURL, CSP headers, preview indexing, and rollback - Browse locally — run
hugo serve -s docswhile writing code and docs side by side - From scratch — standalone OINK setup and offline / submodule install methods
- Configuration — full
hugo.ymlreference, includinggithub_subdir