| 1 |
--- |
| 2 |
title: Documentation |
| 3 |
description: Help us to improve the documentation by identifying issues and suggesting changes. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
aliases: [/contribute/docs/] |
| 7 |
--- |
| 8 |
|
| 9 |
## Introduction |
| 10 |
|
| 11 |
We welcome corrections and improvements to the documentation. The documentation lives in a separate repository from the main project. To contribute: |
| 12 |
|
| 13 |
- For corrections and improvements to existing documentation, submit issues and pull requests to the [documentation repository][]. |
| 14 |
- For documentation of new features, include the documentation changes in your pull request to the [project repository][]. |
| 15 |
|
| 16 |
## Guidelines |
| 17 |
|
| 18 |
Follow Google's [developer documentation style guide][] where practical. |
| 19 |
|
| 20 |
### Writing style |
| 21 |
|
| 22 |
Adhere to these writing style conventions. |
| 23 |
|
| 24 |
- Prefer active voice and present tense. |
| 25 |
|
| 26 |
No → With Hugo you can build a static site.\ |
| 27 |
Yes → Build a static site with Hugo. |
| 28 |
|
| 29 |
No → This will cause Hugo to generate HTML files in the `public` directory.\ |
| 30 |
Yes → Hugo generates HTML files in the `public` directory. |
| 31 |
|
| 32 |
- Use second person instead of third person. |
| 33 |
|
| 34 |
No → Users should exercise caution when deleting files.\ |
| 35 |
Better → You must be cautious when deleting files.\ |
| 36 |
Best → Be cautious when deleting files. |
| 37 |
|
| 38 |
- Minimize adverbs. |
| 39 |
|
| 40 |
No → Hugo is extremely fast.\ |
| 41 |
Yes → Hugo is fast. |
| 42 |
|
| 43 |
- Introduce lists and code examples with a complete sentence, not a fragment. Avoid lead-ins that lack a subject or verb: |
| 44 |
|
| 45 |
No → To copy the repository:\ |
| 46 |
Yes → Use the `git clone` command to copy the repository. |
| 47 |
|
| 48 |
Exception: within the `## Examples` section of a function or method reference page, use a short fragment to introduce each code block after the first. See [function and method reference pages](#function-and-method-reference-pages). |
| 49 |
|
| 50 |
- Use [basic english][] where possible for a global audience. |
| 51 |
- Prioritize current best practices over multiple options or historical information. |
| 52 |
- Avoid parenthetical "e.g." expressions, em dashes, and semicolons. |
| 53 |
|
| 54 |
No → Use inline elements (e.g., `strong`, `em`) sparingly.\ |
| 55 |
Yes → Use inline elements such as `strong` and `em` sparingly. |
| 56 |
|
| 57 |
### Markdown |
| 58 |
|
| 59 |
Adhere to these Markdown conventions: |
| 60 |
|
| 61 |
- Use [ATX][] headings (levels 2-4), not [setext][] headings. |
| 62 |
- Use [collapsed link references][] instead of full or shortcut references. For example: |
| 63 |
|
| 64 |
```md {file="content/example.md"} |
| 65 |
This is a [link][]. |
| 66 |
|
| 67 |
[link]: https://example.org |
| 68 |
``` |
| 69 |
|
| 70 |
- Use [inline links][] to link to fragments on the same page. For example: |
| 71 |
|
| 72 |
```md {file="content/example.md"} |
| 73 |
This is a link to a [fragment][#fragment]. |
| 74 |
``` |
| 75 |
|
| 76 |
- Use [fenced code blocks][] instead of [indented code blocks][]. |
| 77 |
- Use hyphens, not asterisks, for unordered [list items][]. |
| 78 |
- Prefix each ordered list item with `1.` instead of numbering the items sequentially. |
| 79 |
- Use [callouts](#callouts) instead of bold text for emphasis. |
| 80 |
- Do not mix [raw HTML][] within Markdown. |
| 81 |
- Do not use bold text in place of a heading or description term (`dt`). |
| 82 |
- Do not use Hugo's `ref` or `relref` shortcodes. |
| 83 |
- Do not place a list immediately after a heading; always precede it with a sentence. |
| 84 |
- Remove consecutive blank lines. |
| 85 |
- Remove trailing spaces. |
| 86 |
|
| 87 |
### Section headings |
| 88 |
|
| 89 |
Do not use formatting, such as backticks, bold, or italic, in section headings, levels `h1` through `h6`. |
| 90 |
|
| 91 |
- Use sentence-style capitalization. |
| 92 |
- Keep them concise. |
| 93 |
- Do not create a single subsection under a section; either add more subsections or remove the heading. This also applies to a single level 2 heading on an otherwise unheaded page: either add a second level 2 heading, or remove it and let the content flow as body text. |
| 94 |
- Precede the first subheading under a heading with a sentence introducing the subsections, unless the heading text alone makes the subsections' purpose obvious. |
| 95 |
|
| 96 |
### File paths and names |
| 97 |
|
| 98 |
Wrap directory names, file names, and file paths in backticks. |
| 99 |
|
| 100 |
### Shortcode names |
| 101 |
|
| 102 |
Wrap shortcode names in backticks. Link to the shortcode page using the name as the link text, not the word "shortcode": |
| 103 |
|
| 104 |
```md {file="content/example.md"} |
| 105 |
Use the [`highlight`] shortcode to render syntax-highlighted code. |
| 106 |
|
| 107 |
[`highlight`]: /shortcodes/highlight/ |
| 108 |
``` |
| 109 |
|
| 110 |
### Glossary |
| 111 |
|
| 112 |
[Glossary][] terms are defined on individual pages, providing a central repository for definitions, though these pages are not directly linked from the site. |
| 113 |
|
| 114 |
Definitions must be complete sentences, with the first sentence defining the term. Italicize the first occurrence of the term and the first occurrence of any referenced glossary terms for consistency. |
| 115 |
|
| 116 |
Link to glossary terms using this syntax: `[term](g)` |
| 117 |
|
| 118 |
Term lookups are case-insensitive, ignore formatting, and support singular and plural forms. For example, all of these variations will link to the same glossary term: |
| 119 |
|
| 120 |
```md {file="content/example.md"} |
| 121 |
[global resource](g) |
| 122 |
[Global Resource](g) |
| 123 |
[Global Resources](g) |
| 124 |
[`Global Resources`](g) |
| 125 |
``` |
| 126 |
|
| 127 |
Use the [`glossary-term`](#glossary-term) shortcode to insert a term definition: |
| 128 |
|
| 129 |
```md {file="content/example.md"} |
| 130 |
{{%/* glossary-term "global resource" */%}} |
| 131 |
``` |
| 132 |
|
| 133 |
### Terminology |
| 134 |
|
| 135 |
Link to the [glossary][] as needed and use terms consistently. Pay particular attention to: |
| 136 |
|
| 137 |
- "client side" (noun), "client-side" (adjective) |
| 138 |
- "file name" (two words) |
| 139 |
- "flag" (instead of "option" for command-line flags) |
| 140 |
- "front matter" (two words, except when referring to the configuration key) |
| 141 |
- "home page" (two words) |
| 142 |
- "map" (instead of "dictionary") |
| 143 |
- "Markdown" (capitalized) |
| 144 |
- "Node.js" (first mention per page), "Node" (subsequent mentions), "node" (for the executable), "npm" (always lowercase) |
| 145 |
- "open source" (noun), "open-source" (adjective) |
| 146 |
- "server side" (noun), "server-side" (adjective) |
| 147 |
- "standalone" (noun or adjective) |
| 148 |
- "stylesheet" (one word) |
| 149 |
- "website" (one word) |
| 150 |
|
| 151 |
### Products and executables |
| 152 |
|
| 153 |
Distinguish between a product or project and its command-line executable. |
| 154 |
|
| 155 |
- Can you buy it, download it, or read about it? It is a product or project: capitalize it and use plain text. For example: Hugo, Rclone, Docker. |
| 156 |
- Can you run it, type it in a terminal, or install its package? It is a tool or executable: use lowercase and wrap it in backticks. For example: `hugo`, `rclone`, `docker`. |
| 157 |
|
| 158 |
Context|Meaning|Example |
| 159 |
:--|:--|:-- |
| 160 |
Product or project|The framework, website, or community|"Welcome to the Hugo community." |
| 161 |
Documentation|The official guides or site|"Read the Rclone documentation." |
| 162 |
CLI or binary|The command you run, or its path|"Run `hugo server` to preview your site." |
| 163 |
Package|The software installed on a system|"Ensure `rclone` is installed." |
| 164 |
|
| 165 |
### Template types |
| 166 |
|
| 167 |
When you refer to a template type, italicize it: |
| 168 |
|
| 169 |
```md {file="content/example.md"} |
| 170 |
When creating a _taxonomy_ template, do this... |
| 171 |
``` |
| 172 |
|
| 173 |
However, if the template type is also a link, do not italicize it to avoid distracting formatting: |
| 174 |
|
| 175 |
```md {file="content/example.md"} |
| 176 |
When creating a [taxonomy][] template, do this... |
| 177 |
``` |
| 178 |
|
| 179 |
Do not italicize the template type in a title, heading, or front matter description. |
| 180 |
|
| 181 |
## Front matter |
| 182 |
|
| 183 |
This site uses the front matter fields listed in the table below. |
| 184 |
|
| 185 |
Of the four required fields, only `title` and `description` require data. |
| 186 |
|
| 187 |
{{< code-toggle file=content/example.md fm=true >}} |
| 188 |
title: The title |
| 189 |
description: The description |
| 190 |
categories: [] |
| 191 |
keywords: [] |
| 192 |
{{< /code-toggle >}} |
| 193 |
|
| 194 |
If quotation marks are required, prefer single quotes to double quotes when possible. |
| 195 |
|
| 196 |
Field|Description|Required |
| 197 |
:--|:--|:-- |
| 198 |
`title`|The page title|:heavy_check_mark: |
| 199 |
`linkTitle`|A short version of the page title| |
| 200 |
`description`|A complete sentence describing the page|:heavy_check_mark: |
| 201 |
`categories`|An array of terms in the categories taxonomy|:heavy_check_mark: [^1] |
| 202 |
`keywords`|An array of keywords used to identify related content|:heavy_check_mark: [^1] |
| 203 |
`publishDate`|Applicable to news items: the publication date| |
| 204 |
`params.alt_title`|An alternate title: used in the "see also" panel if provided| |
| 205 |
`params.functions_and_methods.aliases`|Applicable to function and method pages: an array of alias names| |
| 206 |
`params.functions_and_methods.returnType`|Applicable to function and method pages: the data type returned| |
| 207 |
`params.functions_and_methods.signatures`|Applicable to function and method pages: an array of signatures| |
| 208 |
`params.hide_in_this_section`|Whether to hide the "in this section" panel| |
| 209 |
`params.label`|Applicable to second-level section pages such as concepts, guides, references, and tutorials: a lowercase 3-letter code to identify the section, used in the `related` partial| |
| 210 |
`params.minversion`|Applicable to the quick start page: the minimum Hugo version required| |
| 211 |
`params.permalink`|Reserved for use by the news content adapter| |
| 212 |
`params.reference`|Applicable to glossary entries: a URL for additional information| |
| 213 |
`params.searchable`|Whether to add the content of this page to the search index. The default value is cascaded down from the project configuration; `true` if the page kind is `page`, and `false` if the page kind is one of `home`, `section`, `taxonomy`, or `term`. Add this field to override the default value.| |
| 214 |
`params.show_publish_date`|Whether to show the `publishDate` when rendering the page| |
| 215 |
`weight`|The page weight| |
| 216 |
`aliases`|Previous URLs used to access this page| |
| 217 |
`expirydate`|The expiration date| |
| 218 |
|
| 219 |
### Page titles |
| 220 |
|
| 221 |
Do not use formatting, such as backticks, bold, or italic, in the `title` field in front matter. |
| 222 |
|
| 223 |
- Use sentence-style capitalization. |
| 224 |
- Keep them concise. |
| 225 |
|
| 226 |
### Page descriptions |
| 227 |
|
| 228 |
Do not use formatting, such as backticks, bold, or italic, in the `description` field in front matter. |
| 229 |
|
| 230 |
When writing the page `description` use imperative present tense when possible. For example: |
| 231 |
|
| 232 |
{{< code-toggle file=content/en/functions/data/_index.md fm=true >}} |
| 233 |
title: Cast functions |
| 234 |
description: Use these functions to cast a value from one data type to another. |
| 235 |
{{< /code-toggle >}} |
| 236 |
|
| 237 |
### Related content |
| 238 |
|
| 239 |
When available, the "See also" sidebar displays related pages using Hugo's [related content][] feature, based on front matter keywords. We ensure consistent keyword usage by validating them against `data/keywords.yaml` during the build. If a keyword is not found, you'll be alerted and must either modify the keyword or update the data file. This validation process helps to refine the related content for better results. |
| 240 |
|
| 241 |
If the title in the "See also" sidebar is ambiguous or the same as another page, you can define an alternate title in the front matter: |
| 242 |
|
| 243 |
{{< code-toggle file=hugo >}} |
| 244 |
title = 'Long descriptive title' |
| 245 |
linkTitle = 'Short title' |
| 246 |
[params] |
| 247 |
alt_title = 'Whatever you want' |
| 248 |
{{< /code-toggle >}} |
| 249 |
|
| 250 |
Use of the alternate title is limited to the "See also" sidebar. |
| 251 |
|
| 252 |
> [!NOTE] |
| 253 |
> Think carefully before setting the `alt_title`. Use it only when necessary. |
| 254 |
|
| 255 |
## Function and method reference pages |
| 256 |
|
| 257 |
For function and method pages, start the front matter `description` with "Returns" to describe the value returned, or with "Reports whether" if the returned value is a boolean. If a function or method is used primarily for its side effects, describe the action it performs instead, using third-person present tense. For example: |
| 258 |
|
| 259 |
- `Returns a slice containing the elements after the first N elements of the given slice.` |
| 260 |
- `Reports whether the given page is in the given section.` |
| 261 |
- `Logs a WARNING from a template.` |
| 262 |
|
| 263 |
Structure the body of a function or method reference page with two level 2 headings, in this order: |
| 264 |
|
| 265 |
1. `## Usage`: prose describing behavior, arguments, and edge cases. |
| 266 |
1. `## Examples`: code blocks demonstrating the function or method. |
| 267 |
|
| 268 |
Open the `## Usage` section with a complete sentence that names the function or method by its canonical form, wrapped in backticks. Use the canonical form even when an alias exists. |
| 269 |
|
| 270 |
No → The `eq` function reports whether the first argument is equal to any of the subsequent arguments.\ |
| 271 |
Yes → The `compare.Eq` function reports whether the first argument is equal to any of the subsequent arguments. |
| 272 |
|
| 273 |
This opening sentence typically overlaps with the front matter `description`. This is expected and intentional. Do not avoid or rephrase this overlap. |
| 274 |
|
| 275 |
When prose names an argument placeholder taken verbatim from the function's signature, wrap it in backticks. This does not apply when the argument is described in plain English instead of by its placeholder name. |
| 276 |
|
| 277 |
No → If CONTROL is truthy the function returns ARG1, otherwise it returns ARG2.\ |
| 278 |
Yes → If `CONTROL` is truthy the function returns `ARG1`, otherwise it returns `ARG2`. |
| 279 |
|
| 280 |
Under `## Examples`, use one or more `go-html-template` code blocks to demonstrate the function or method. Always call the function or method by its canonical form, as described in [code examples](#code-examples). |
| 281 |
|
| 282 |
The first code block needs no lead-in sentence. Introduce each subsequent code block with a short lead-in ending in a colon. Do not repeat the function's name, and do not restate the `## Usage` prose: |
| 283 |
|
| 284 |
````md {file="content/example.md"} |
| 285 |
## Examples |
| 286 |
|
| 287 |
```go-html-template |
| 288 |
{{ compare.Eq 1 1 }} → true |
| 289 |
{{ compare.Eq 1 2 }} → false |
| 290 |
``` |
| 291 |
|
| 292 |
Comparing numbers of different types: |
| 293 |
|
| 294 |
```go-html-template |
| 295 |
{{ compare.Eq 1 1.0 }} → true |
| 296 |
``` |
| 297 |
```` |
| 298 |
|
| 299 |
## Code examples |
| 300 |
|
| 301 |
Use short, focused code examples. When including template code examples, follow these conventions. |
| 302 |
|
| 303 |
- Indent with two spaces. |
| 304 |
- Insert a space after an opening action delimiter. |
| 305 |
- Insert a space before a closing action delimiter. |
| 306 |
- Do not add white space removal syntax to action delimiters unless required. For example, inline elements like `img` and `a` require whitespace removal on both sides. |
| 307 |
- Call a function or method by its canonical form, even when a legacy alias exists. |
| 308 |
|
| 309 |
No → `{{ eq 1 1 }}`\ |
| 310 |
Yes → `{{ compare.Eq 1 1 }}` |
| 311 |
|
| 312 |
Exception: pages whose purpose is to document aliases themselves may use aliases when specifically illustrating alias usage. |
| 313 |
|
| 314 |
- Do not update version references to third-party libraries embedded within Hugo (for example, the KaTeX display engine used by the `transform.ToMath` function) unless the embedded library version changes in Hugo's source code. |
| 315 |
|
| 316 |
````md {file="content/example.md"} |
| 317 |
```go-html-template |
| 318 |
{{ if eq $foo $bar }} |
| 319 |
{{ fmt.Printf "%s is %s" $foo $bar }} |
| 320 |
{{ end }} |
| 321 |
``` |
| 322 |
```` |
| 323 |
|
| 324 |
### Fenced code blocks |
| 325 |
|
| 326 |
The code block render hook performs several language substitutions: |
| 327 |
|
| 328 |
Given language|Substitution|Reason |
| 329 |
:--|:--|:-- |
| 330 |
`html`, `gotmpl`|`go-html-template`|Consistent rendering |
| 331 |
`bash`, `ksh`, `sh`, `shell`, `zsh`|`text`|Avoid highlighting quirks |
| 332 |
`md`, `mkd`|`text`|Avoid highlighting quirks |
| 333 |
`tree`|`text`|There isn't a `tree` lexer |
| 334 |
|
| 335 |
Set the language to `go-html-template` when including template examples: |
| 336 |
|
| 337 |
````md {file="content/example.md"} |
| 338 |
```go-html-template |
| 339 |
{{ if eq $foo "bar" }} |
| 340 |
{{ print "foo is bar" }} |
| 341 |
{{ end }} |
| 342 |
``` |
| 343 |
```` |
| 344 |
|
| 345 |
Set the language to `md` when including Markdown examples: |
| 346 |
|
| 347 |
````md {file="content/example.md"} |
| 348 |
```md |
| 349 |
This is **bold** text. |
| 350 |
``` |
| 351 |
```` |
| 352 |
|
| 353 |
Set the language to `sh` when including command line examples: |
| 354 |
|
| 355 |
````md {file="content/example.md"} |
| 356 |
```sh |
| 357 |
hugo server -D |
| 358 |
``` |
| 359 |
```` |
| 360 |
|
| 361 |
Set the language to `tree` when documenting the output of the `tree` command: |
| 362 |
|
| 363 |
````md {file="content/example.md"} |
| 364 |
```tree |
| 365 |
assets/ |
| 366 |
└── images/ |
| 367 |
└── sunset.jpg |
| 368 |
``` |
| 369 |
```` |
| 370 |
|
| 371 |
Use the `file` and `copy` attributes to include a file name header and copy-to-clipboard button. |
| 372 |
|
| 373 |
````md {file="content/example.md"} |
| 374 |
```go-html-template {file="layouts/_partials/foo.html" copy=true} |
| 375 |
{{ if eq $foo "bar" }} |
| 376 |
{{ print "foo is bar" }} |
| 377 |
{{ end }} |
| 378 |
``` |
| 379 |
```` |
| 380 |
|
| 381 |
Use the `details`, `open`, and `summary` attributes to wrap the code block in an initially-opened `details` element with a custom summary. |
| 382 |
|
| 383 |
````md {file="content/example.md"} |
| 384 |
```go-html-template {details=true open=true summary="layouts/_partials/foo.html" copy=true} |
| 385 |
{{ if eq $foo "bar" }} |
| 386 |
{{ print "foo is bar" }} |
| 387 |
{{ end }} |
| 388 |
``` |
| 389 |
```` |
| 390 |
|
| 391 |
Whitespace trimming is enabled by default. Use `trim=false` to preserve leading and trailing whitespace. |
| 392 |
|
| 393 |
````md {file="content/example.md"} |
| 394 |
```go-html-template {trim=false} |
| 395 |
|
| 396 |
{{ if eq $foo "bar" }} |
| 397 |
{{ print "foo is bar" }} |
| 398 |
{{ end }} |
| 399 |
|
| 400 |
``` |
| 401 |
```` |
| 402 |
|
| 403 |
### Escaping shortcode syntax |
| 404 |
|
| 405 |
Use this syntax to escape a shortcode call within examples: |
| 406 |
|
| 407 |
```md {file="content/example.md"} |
| 408 |
{{</*/* foo */*/>}} |
| 409 |
{{%/*/* foo */*/%}} |
| 410 |
``` |
| 411 |
|
| 412 |
### Project configuration |
| 413 |
|
| 414 |
Use the [`code-toggle`](#code-toggle) shortcode to include project configuration examples: |
| 415 |
|
| 416 |
```md {file="content/example.md"} |
| 417 |
{{</* code-toggle file=hugo */>}} |
| 418 |
baseURL = 'https://example.org/' |
| 419 |
locale = 'en-US' |
| 420 |
title = 'My Site' |
| 421 |
{{</* /code-toggle */>}} |
| 422 |
``` |
| 423 |
|
| 424 |
### Front matter examples |
| 425 |
|
| 426 |
Use the [`code-toggle`](#code-toggle) shortcode to include front matter example, setting the `fm` attribute to `true`: |
| 427 |
|
| 428 |
```md {file="content/example.md"} |
| 429 |
{{</* code-toggle file=content/posts/my-first-post.md fm=true */>}} |
| 430 |
title = 'My first post' |
| 431 |
date = 2023-11-09T12:56:07-08:00 |
| 432 |
draft = false |
| 433 |
{{</* /code-toggle */>}} |
| 434 |
``` |
| 435 |
|
| 436 |
## Callouts |
| 437 |
|
| 438 |
Use callouts, also known as admonitions, to visually emphasize important information. |
| 439 |
|
| 440 |
There are five callout types: `note`, `important`, `tip`, `warning`, and `caution`. The callout type is case-insensitive. |
| 441 |
|
| 442 |
```md {file="content/example.md"} |
| 443 |
> [!NOTE] |
| 444 |
> Useful information that users should know, even when skimming content. |
| 445 |
``` |
| 446 |
|
| 447 |
> [!NOTE] |
| 448 |
> Useful information that users should know, even when skimming content. |
| 449 |
|
| 450 |
```md {file="content/example.md"} |
| 451 |
> [!IMPORTANT] |
| 452 |
> Key information users need to know to achieve their goal. |
| 453 |
``` |
| 454 |
|
| 455 |
> [!IMPORTANT] |
| 456 |
> Key information users need to know to achieve their goal. |
| 457 |
|
| 458 |
```md {file="content/example.md"} |
| 459 |
> [!TIP] |
| 460 |
> Helpful advice for doing things better or more easily. |
| 461 |
``` |
| 462 |
|
| 463 |
> [!TIP] |
| 464 |
> Helpful advice for doing things better or more easily. |
| 465 |
|
| 466 |
```md {file="content/example.md"} |
| 467 |
> [!WARNING] |
| 468 |
> Urgent info that needs immediate user attention to avoid problems. |
| 469 |
``` |
| 470 |
|
| 471 |
> [!WARNING] |
| 472 |
> Urgent info that needs immediate user attention to avoid problems. |
| 473 |
|
| 474 |
```md {file="content/example.md"} |
| 475 |
> [!CAUTION] |
| 476 |
> Advises about risks or negative outcomes of certain actions. |
| 477 |
``` |
| 478 |
|
| 479 |
> [!CAUTION] |
| 480 |
> Advises about risks or negative outcomes of certain actions. |
| 481 |
|
| 482 |
## Shortcodes |
| 483 |
|
| 484 |
These shortcodes are commonly used throughout the documentation. Other shortcodes are available for specialized use. |
| 485 |
|
| 486 |
### code-toggle |
| 487 |
|
| 488 |
Use the `code-toggle` shortcode to display examples of project configuration, front matter, or data files. This shortcode takes these arguments: |
| 489 |
|
| 490 |
`config` |
| 491 |
: (`string`) The section of `hugo.Data.docs.config` to render. |
| 492 |
|
| 493 |
`copy` |
| 494 |
: (`bool`) Whether to display a copy-to-clipboard button. Default is `false`. |
| 495 |
|
| 496 |
`datakey` |
| 497 |
: (`string`) The section of `hugo.Data.docs` to render. |
| 498 |
|
| 499 |
`file` |
| 500 |
: (`string`) The file name to display above the rendered code. Omit the file extension for project configuration examples. |
| 501 |
|
| 502 |
`fm` |
| 503 |
: (`bool`) Whether to render the code as front matter. Default is `false`. |
| 504 |
|
| 505 |
`skipHeader` |
| 506 |
: (`bool`) Whether to omit top-level key(s) when rendering a section of `hugo.Data.docs.config`. |
| 507 |
|
| 508 |
```md {file="content/example.md"} |
| 509 |
{{</* code-toggle file=hugo copy=true */>}} |
| 510 |
baseURL = 'https://example.org/' |
| 511 |
locale = 'en-US' |
| 512 |
title = 'My Site' |
| 513 |
{{</* /code-toggle */>}} |
| 514 |
``` |
| 515 |
|
| 516 |
### deprecated-in |
| 517 |
|
| 518 |
Use the `deprecated-in` shortcode to indicate that a feature is deprecated: |
| 519 |
|
| 520 |
```md |
| 521 |
{{</* deprecated-in 0.144.0 /*/>}} |
| 522 |
``` |
| 523 |
|
| 524 |
You can also include details: |
| 525 |
|
| 526 |
```md |
| 527 |
{{</* deprecated-in 0.144.0 */>}} |
| 528 |
Use the [`hugo.IsServer`](/docs/reference/functions/hugo/isserver/) function instead. |
| 529 |
{{</* /deprecated-in */>}} |
| 530 |
``` |
| 531 |
|
| 532 |
The shortcode triggers a build warning if the specified version is older than a predefined threshold, based on differences in major and minor versions. This serves as a reminder to remove the shortcode call and the associated content. See [details][]. |
| 533 |
|
| 534 |
When deprecating a feature that has its own page, also set the `expiryDate` in front matter to two years from the date of deprecation. Include a brief comment to explain the setting: |
| 535 |
|
| 536 |
```yaml |
| 537 |
expiryDate: 2028-03-03 # deprecated 2026-03-03 in v0.157.0 |
| 538 |
``` |
| 539 |
|
| 540 |
### eturl |
| 541 |
|
| 542 |
Use the embedded template URL (`eturl`) shortcode to insert an absolute URL to the source code for an embedded template. The shortcode takes a single argument, the base file name of the template (omit the file extension). |
| 543 |
|
| 544 |
```md {file="content/example.md"} |
| 545 |
This is a link to the [embedded alias template][]. |
| 546 |
|
| 547 |
[embedded alias template]: <{{%/* eturl alias */%}}> |
| 548 |
``` |
| 549 |
|
| 550 |
The `eturl` shortcode looks up URLs in `data/embedded_template_urls.toml`. |
| 551 |
|
| 552 |
### glossary-term |
| 553 |
|
| 554 |
Use the `glossary-term` shortcode to insert the definition of the given glossary term. |
| 555 |
|
| 556 |
```md {file="content/example.md"} |
| 557 |
{{%/* glossary-term scalar */%}} |
| 558 |
``` |
| 559 |
|
| 560 |
### include |
| 561 |
|
| 562 |
Use the `include` shortcode to include content from another page. |
| 563 |
|
| 564 |
```md {file="content/example.md"} |
| 565 |
{{%/* include "_common/content-format-table.md" */%}} |
| 566 |
``` |
| 567 |
|
| 568 |
### new-in |
| 569 |
|
| 570 |
Use the `new-in` shortcode to indicate a new feature: |
| 571 |
|
| 572 |
```md {file="content/example.md"} |
| 573 |
{{</* new-in 0.144.0 /*/>}} |
| 574 |
``` |
| 575 |
|
| 576 |
You can also include details: |
| 577 |
|
| 578 |
```md {file="content/example.md"} |
| 579 |
{{</* new-in 0.144.0 */>}} |
| 580 |
This is a new feature. |
| 581 |
{{</* /new-in */>}} |
| 582 |
``` |
| 583 |
|
| 584 |
The shortcode triggers a build warning if the specified version is older than a predefined threshold, based on differences in major and minor versions. This serves as a reminder to remove the shortcode call. See [details][]. |
| 585 |
|
| 586 |
## GitHub workflow |
| 587 |
|
| 588 |
> [!NOTE] |
| 589 |
> This section assumes that you have a working knowledge of Git and GitHub, and are comfortable working on the command line. |
| 590 |
|
| 591 |
Use this workflow to create and submit pull requests. |
| 592 |
|
| 593 |
Step 1 |
| 594 |
: Fork the [documentation repository][]. |
| 595 |
|
| 596 |
Step 2 |
| 597 |
: Clone your fork. |
| 598 |
|
| 599 |
Step 3 |
| 600 |
: Create a new branch with a descriptive name that includes the corresponding issue number, if any: |
| 601 |
|
| 602 |
```sh |
| 603 |
git checkout -b restructure-foo-page-99999 |
| 604 |
``` |
| 605 |
|
| 606 |
Step 4 |
| 607 |
: Make changes. |
| 608 |
|
| 609 |
Step 5 |
| 610 |
: Build the site locally to preview your changes. |
| 611 |
|
| 612 |
Step 6 |
| 613 |
: Commit your changes with a descriptive commit message: |
| 614 |
|
| 615 |
- Provide a summary on the first line, typically 50 characters or less, followed by a blank line. |
| 616 |
- Begin the summary with one of `content`, `theme`, `config`, `all`, or `misc`, followed by a colon, a space, and a brief description of the change beginning with a capital letter |
| 617 |
- Use imperative present tense |
| 618 |
- Optionally, provide a detailed description where each line is 72 characters or less, followed by a blank line. |
| 619 |
- Optionally, add one or more "Fixes" or "Closes" keywords, each on its own line, referencing the [issues][] addressed by this change. |
| 620 |
|
| 621 |
For example: |
| 622 |
|
| 623 |
```sh |
| 624 |
git commit -m "content: Restructure the taxonomy page |
| 625 |
|
| 626 |
This restructures the taxonomy page by splitting topics into logical |
| 627 |
sections, each with one or more examples. |
| 628 |
|
| 629 |
Fixes #9999 |
| 630 |
Closes #9998" |
| 631 |
``` |
| 632 |
|
| 633 |
Step 7 |
| 634 |
: Push the new branch to your fork of the documentation repository. |
| 635 |
|
| 636 |
Step 8 |
| 637 |
: Visit the [documentation repository][] and create a pull request (PR). |
| 638 |
|
| 639 |
Step 9 |
| 640 |
: A project maintainer will review your PR and may request changes. You may delete your branch after the maintainer merges your PR. |
| 641 |
|
| 642 |
[^1]: The field is required, but its data is not. |
| 643 |
|
| 644 |
[ATX]: https://spec.commonmark.org/current/#atx-headings |
| 645 |
[Glossary]: /quick-reference/glossary/ |
| 646 |
[basic english]: https://simple.wikipedia.org/wiki/Basic_English |
| 647 |
[collapsed link references]: https://discourse.gohugo.io/t/55714 |
| 648 |
[details]: https://github.com/gohugoio/hugoDocs/blob/master/layouts/_partials/layouts/blocks/feature-state.html |
| 649 |
[developer documentation style guide]: https://developers.google.com/style |
| 650 |
[documentation repository]: https://github.com/gohugoio/hugoDocs/ |
| 651 |
[fenced code blocks]: https://spec.commonmark.org/current/#fenced-code-blocks |
| 652 |
[indented code blocks]: https://spec.commonmark.org/current/#indented-code-blocks |
| 653 |
[inline links]: https://discourse.gohugo.io/t/55714 |
| 654 |
[issues]: https://github.com/gohugoio/hugoDocs/issues |
| 655 |
[list items]: https://spec.commonmark.org/current/#list-items |
| 656 |
[project repository]: https://github.com/gohugoio/hugo |
| 657 |
[raw HTML]: https://spec.commonmark.org/current/#raw-html |
| 658 |
[related content]: /content-management/related-content/ |
| 659 |
[setext]: https://spec.commonmark.org/current/#setext-heading |