Includes
When the same installation steps appear on three pages, or the current version
number on thirty, every copy is a chance for the pages to drift apart. These
three shortcodes keep one source instead: include inserts the content of
another file, param prints a page or site parameter, and comment holds a
note for authors that no output ever shows. Content that only one page uses
belongs on that page.
Shortest form
include has one required parameter, file:
The included file is ordinary Markdown, kept under assets/:
It renders exactly as if you had written it here, copy button and callout included:
Installing OINK into an existing Hugo site takes three commands:
hugo mod get needs Go on the machine; an offline archive or a submodule does not.
The current release is v1.8.0.
An included file is not a page: it has no URL, no sidebar entry and no translation of its own.
Where the file comes from
file is looked up in this order, and the first match wins:
- A page resource — a file in this page’s bundle, written as
file="config.yaml". - A global resource under
assets/— written asfile="snippets/dsn.txt". - A file under
content/— a leading/starts at the content root, otherwise relative to the page’s directory, written asfile="notes/caveat.md"orfile="/shared/notice.md".
Include never reads outside content/ and assets/. A path containing ..,
or one that matches nothing, warns and includes nothing.
Keep Markdown fragments under assets/ or content/, where the name you
write is exactly the file you get. In a page bundle (step 1), Hugo files
language-suffixed resources such as notice.zh.md under the name without the
suffix, and asking the bundle for notice.md returns rendered HTML rather than
source, which then leaks into the page’s Markdown output as
<div class="td-code"> markup. Non-Markdown files such as .yaml, .sh or
.txt are not affected.
Including code files
code=true shows the file as a code block, and lang= picks its
highlighting. Including a real configuration file from the repository keeps
the documentation in step with the file.
The block gets the same highlighting, line numbers and copy button as a code
fence. Fence attributes such as title=, collapse or hl_lines= cannot be
passed through include; when you need them, write an ordinary
code block.
What a fragment can contain
A fragment is ordinary Markdown rendered in the context of the page that
includes it, so callouts, tables, lists, images, steps and shortcodes all
work. That is why the last line of the example above shows this site’s current
release: its {{< param version >}} expands on this page.
When two pages include the same fragment, each renders it separately with its own heading anchors and code-block IDs, so nothing collides. Good fragments are the things that must change everywhere at once: installation commands, connection strings, support matrices, legal notices.
Printing a site parameter
param prints one parameter, looking in the page’s front matter first and then
in the site configuration, the same lookup as Hugo’s .Param.
This site publishes v1.8.0, copyright from 2026,
and this page’s front matter says pigsty_pg_major: 18, which reads back as 18.
Join nested keys with .: copyright.from_year reads
params.copyright.from_year. A missing parameter, or one whose value is a map
or a list, warns and prints nothing.
Parameters inside commands, tables and links
param prints escaped plain text, so it also works inside code fences, table
cells and link targets, which is where version numbers usually live:
| Item | Value |
|---|---|
| Current version | v1.8.0 |
| Visual preset | paper |
Site parameters are set in Configuration, page parameters in Front matter.
Notes deleted at build time
Use comment for a to-do or a note to the next author. Its body is dropped
from every output: HTML, print, Markdown and RSS. An HTML comment would not do,
because it stays in the page source and reaches llms.txt.
Since PostgreSQL 18, pg_stat_io breaks out WAL statistics.
Verify the dashboards on a test database before upgrading.
There is a comment between these two paragraphs, and not even the page source shows it.
Output
None of the three shortcodes loads a script, and print and RSS show the same
content as the web page. The page’s Markdown output keeps sources rather than
rendered HTML: an included fragment appears as written, with shortcodes such
as {{< param version >}} still unexpanded, include code=true becomes a
fenced code block, param becomes its value, and comment leaves nothing.
Parameter reference
include (named parameters only):
file, ,- Resolution order in Where the file comes from; a
.., missing file, or empty value warns and emits nothing
Any other parameter name warns, with the file and line, and is ignored.
param (one positional parameter):
comment takes no parameters. It is a paired shortcode, and everything
between {{< comment >}} and {{< /comment >}} is discarded.
Limits
includeis not a template: it cannot pass variables to a fragment, include one conditionally, or add fence attributes such astitle=orcollapseto an included code block. For per-platform variants, write two fragments and put them in tabs.includehas no language fallback and reads exactly the path you write. A fragment can serve every language, or you can keep one per language, as this page does withinstall-oink.mdandinstall-oink.zh.md, and point each translation at its own.paramprints scalars only. Keep structured data such as version matrices or download lists indata/and render it with the matching component.commentdiscards its content on every build. To take a whole page offline for a while, setdraft: true.- If a page needs ten fragments, readers are better served by ten links than by one page assembled from includes.
Related
- Code blocks — every fence attribute, and the pipeline
include code=truereuses - Tabs — per-platform or per-language fragments
- Configuration — the site parameters
paramcan reach - Front matter — page parameters, which win over site configuration