Writing pages
A documentation page is one Markdown file under content/: a few lines of YAML
front matter, then the body. Where you save the file decides its URL and its
place in the sidebar, so a new page needs nothing beyond the file itself:
With hugo server running, the page appears at /docs/install/ and as
Install in the sidebar. If your site does not build yet, start with
Get started.
Creating a page
The path under content/ becomes the URL: content/docs/install.md is
published at /docs/install/. A translation is a file of the same name with a
language suffix, such as install.zh.md, in the same directory, and it shares
the English page’s logical path.
A page with no files of its own is a single .md file. When it has
screenshots, recordings or example configuration, make it a directory instead:
name the page index.md and put its files beside it. Hugo calls this a
page bundle, and the
page refers to its files by their bare names:
the two page shapes inside content/
content/
docs/
- _index.mdsection index, English
- _index.zh.mdsection index, Chinese
- install.mdsingle-file page → /docs/install/
- install.zh.mdits Chinese translation
anatomy/page bundle → /docs/anatomy/
- index.md
- index.zh.md
- shell.webppage resource, shared by both languages
Both shapes look the same in the sidebar. hugo new content docs/install.md
creates the file with front matter from an
archetype; writing it by hand
works just as well. A bundle resource without a language suffix is shared by
every language. File naming and resources
explains language-specific resources and the one case that needs them: a page
that exists only in Chinese.
The front matter you need
The YAML between the two --- lines at the top of the file is the front
matter. Four keys belong on every page:
Write description as one sentence saying what the reader can do with the
page. It appears on section index cards, in search results and on social
cards, so it is what someone reads when deciding whether to open the page.
weight orders the page among its siblings; Ordering
explains ties and pages without one.
Every other key is optional: an icon, draft status, a search boost, comments, the page shell. Page parameters lists them all.
Heading levels and stable anchors
Start body sections at ##. The theme renders title as the page’s one #
heading, so a # in the body would add a second. The outline in the right
column lists headings from ## down to Hugo’s
markup.tableOfContents.endLevel, which is ### unless you set it to 4 to
include ####.
Give every ## and ### an explicit English ID:
Without an explicit ID, Hugo derives one from the heading text, which causes two problems:
-
A translated heading gets a different ID (
#前提条件instead of#prerequisites), so a link that works in English lands at the top of the Chinese page. With the English ID on both,/docs/install/#prerequisitesand/zh/docs/install/#prerequisitesreach the same place; see Heading anchors must align. -
Rewording a heading silently breaks every link to it. Treat a published ID as part of the URL, and when you must rename one, leave an empty anchor with the old ID so existing links still arrive:
Source: leaving a target behind for the old anchor
Use lowercase English words joined by hyphens, unique within the page.
OINK’s Markdown extensions
The body is standard Markdown, rendered by Hugo’s Goldmark, plus the forms below. Each is ordinary Markdown with at most one attribute line, so the source still reads well on GitHub or in any editor:
| Component | Shortest syntax | Page |
|---|---|---|
| Callouts | > [!NOTE] on the first line of a blockquote; > [!SOCIAL] quotes a social post |
Callouts · Social |
| Code blocks | {title="hugo.yml" copy=false} on the fence info line |
Code Blocks |
| Table extras | A table followed by {.matrix} or {caption="…"} |
Tables |
| Field lists | A table followed by {.fields meta="type default"} |
Fields |
| Tabs | Two adjacent fences each carrying {tab="Homebrew"} |
Tabs |
| Steps | An ordered list followed by a {.steps} line |
Steps |
| Timelines | A definition list followed by a {.timeline} line |
Timelines |
| Updates | A heading with {.update date="…" tags="…"} |
Updates |
| Cards | A list of links followed by a {.cards} line |
Cards |
| Diagrams | A mermaid fence (also plantuml, markmap, echarts) |
Mermaid |
| Maps | A map fence with a YAML or JSON list of places |
Maps |
| File trees | A filetree fence, one - name/ # comment per line |
FileTree |
| Mathematics | A math fence, or display math wrapped in $$ |
Math |
| Images & media | A standalone image/video/audio line followed by {caption="…"} |
Images · Video · Audio |
The few components that need more than Markdown can express use shortcodes:
badges, keyboard keys (bare <kbd> also renders as a keycap), file includes,
terminal recordings, and the Book figure and table family. Their syntax is in Components.
The forms combine. Here a code fence and a callout sit inside steps:
- Install PostgreSQL 18:
- Start the server and connect to it:
Tip
brew services listshows whether the server is running.
Writing links
Choose the form by what the link points at:
| Form | Example | When to use it |
|---|---|---|
| Absolute site path | [Configuration](/docs/customize/config/) |
The default. It names the published route, survives moving the source file, and is easy to find and replace across the site |
| Relative path | [another page](../organize/),  |
Resources in the same page bundle, or a neighboring page that should move with its source directory |
The ref / relref shortcode |
[Configuration]({{< ref "/docs/customize/config" >}}) |
A target that must exist: a missing one fails the build instead of leaving a broken link |
All three point at directory-style routes with a trailing slash
(/docs/write/pages/), the way Hugo publishes pages by default. In a
bilingual site, link to the logical page rather than to a .zh.md file, and
use the same fragment IDs in both languages.
Plain Markdown links are not checked when the site builds, so:
- Write internal links as absolute paths; after a restructure, one site-wide search and replace finds them all.
- When you move a page, add its old path to
aliasesso outside links keep working, and point your own links at the new route instead of leaning on the alias. - When you are not sure a target exists, use
refand let the build check it.
The theme passes links to Goldmark unchanged; it has no link render hook.
External links therefore open in the same tab. For new tabs, write the link as
HTML or add your own layouts/_markup/render-link.html.
Where images go
Put a page’s own screenshots in its page bundle, images several pages share in
assets/images/, and large files that need no processing in static/. All
three use the same  syntax, and an attribute line below the
image adds a caption, a size, zoom or a figure number; see
Images.
Drafts and publishing
Mark an unfinished page draft: true and no build publishes it:
hugo server -D (--buildDrafts) previews drafts. A page whose date lies in
the future is left out the same way until you build after that date, and -F
(--buildFuture) previews it. Production builds use neither flag, so plain
hugo publishes only finished pages.
What appears at the end of a page
Do not write a feedback prompt, a last-updated line, previous/next links or a comment box into the body. The theme adds them after the last paragraph, always in this order:
| Block | Default | Off for one page | Configure |
|---|---|---|---|
| Share bar | Off until params.ui.share lists networks |
share: false |
Blog posts |
| Feedback: the two “Was this page helpful?” buttons | Off | feedback: false |
Repository links and page info |
| Last modified: the time and the latest commit subject, linked to GitHub | On when Git information is available | annotation: false |
Repository links and page info |
| Pager: previous and next, in sidebar order | On for docs, book and blog | pager: false |
Navigation and menus |
| Comments: Giscus | On when configured and enabled | comments: false |
Comments |
The action menu beside the title (copy as Markdown, edit this page, view history, open an issue, print) is generated too, and is configured in Repository links and page info. Why the blocks come in this order is explained in What the page end is made of.
Verify
Build once after writing a page:
The build should end with Total in … and no ERROR. A mistyped attribute or
component parameter produces a warning with its source position and renders a
safe fallback, as described in
Configuration principles; a ref to a
missing page fails the build. --printPathWarnings reports two pages that
publish to the same path, which happens most often in multilingual sites or
after a change to permalinks.
Then check in the browser:
- The page sits in the sidebar where its
weightputs it. - The right-hand outline lists your
##headings, and clicking one puts an English anchor in the URL. - A heading has the same anchor on the English page and on its translation.
Related
- Organizing content — how the directory structure decides the sidebar
- Page parameters — the full front matter table
- Components — each component’s syntax and parameters
- Languages — paired bilingual files and fallback for untranslated pages
- Local preview — the
hugo serverswitches worth knowing