Debian Codegraph @

docs/content/en/contribute/documentation/index.md

raw
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 ### Style
19
20 Follow Google's [developer documentation style guide][] where practical.
21
22 ### Markdown
23
24 Adhere to these Markdown conventions:
25
26 - Use [ATX][] headings (levels 2-4), not [setext][] headings.
27 - Use [collapsed link references][] instead of full or shortcut references. For example:
28
29 ```md {file="content/example.md"}
30 This is a [link][].
31
32 [link]: https://example.org
33 ```
34
35 - Use [inline links][] to link to fragments on the same page. For example:
36
37 ```md {file="content/example.md"}
38 This is a link to a [fragment][#fragment].
39 ```
40
41 - Use [fenced code blocks][] instead of [indented code blocks][].
42 - Use hyphens, not asterisks, for unordered [list items][].
43 - Prefix each ordered list item with `1.` instead of numbering the items sequentially.
44 - Use [callouts](#callouts) instead of bold text for emphasis.
45 - Do not mix [raw HTML][] within Markdown.
46 - Do not use bold text in place of a heading or description term (`dt`).
47 - Remove consecutive blank lines.
48 - Remove trailing spaces.
49
50 ### Glossary
51
52 [Glossary][] terms are defined on individual pages, providing a central repository for definitions, though these pages are not directly linked from the site.
53
54 Definitions must be complete sentences, with the first sentence defining the term. Italicize the first occurrence of the term and any referenced glossary terms for consistency.
55
56 Link to glossary terms using this syntax: `[term](g)`
57
58 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:
59
60 ```md {file="content/example.md"}
61 [global resource](g)
62 [Global Resource](g)
63 [Global Resources](g)
64 [`Global Resources`](g)
65 ```
66
67 Use the [glossary-term shortcode](#glossary-term) to insert a term definition:
68
69 ```md {file="content/example.md"}
70 {{%/* glossary-term "global resource" */%}}
71 ```
72
73 ### Terminology
74
75 Link to the [glossary][] as needed and use terms consistently. Pay particular attention to:
76
77 - "client side" (noun), "client-side" (adjective)
78 - "file name" (two words)
79 - "flag" (instead of "option" for command-line flags)
80 - "front matter" (two words, except when referring to the configuration key)
81 - "home page" (two words)
82 - "map" (instead of "dictionary")
83 - "Markdown" (capitalized)
84 - "Node.js" (first mention per page), "Node" (subsequent mentions), "node" (for the executable), "npm" (always lowercase)
85 - "open source" (noun), "open-source" (adjective)
86 - "server side" (noun), "server-side" (adjective)
87 - "standalone" (noun or adjective)
88 - "stylesheet" (one word)
89 - "website" (one word)
90
91 ### Template types
92
93 When you refer to a template type, italicize it:
94
95 ```md {file="content/example.md"}
96 When creating a _taxonomy_ template, do this...
97 ```
98
99 However, if the template type is also a link, do not italicize it to avoid distracting formatting:
100
101 ```md {file="content/example.md"}
102 When creating a [taxonomy][] template, do this...
103 ```
104
105 Do not italicize the template type in a title, heading, or front matter description.
106
107 ### Titles and headings
108
109 - Use sentence-style capitalization.
110 - Avoid formatted strings.
111 - Keep them concise.
112
113 ### Page descriptions
114
115 When writing the page `description` use imperative present tense when possible. For example:
116
117 {{< code-toggle file=content/en/functions/data/_index.md fm=true >}}
118 title: Data functions
119 linkTitle: data
120 description: Use these functions to read local or remote data files.
121 {{< /code-toggle >}}
122
123 ### Writing style
124
125 Prefer active voice and present tense.
126
127 No → With Hugo you can build a static site.\
128 Yes → Build a static site with Hugo.
129
130 No → This will cause Hugo to generate HTML files in the `public` directory.\
131 Yes → Hugo generates HTML files in the `public` directory.
132
133 Use second person instead of third person.
134
135 No → Users should exercise caution when deleting files.\
136 Better → You must be cautious when deleting files.\
137 Best → Be cautious when deleting files.
138
139 Minimize adverbs.
140
141 No → Hugo is extremely fast.\
142 Yes → Hugo is fast.
143
144 > [!NOTE]
145 > "It's an adverb, Sam. It's a lazy tool of a weak mind." (Outbreak, 1995).
146
147 ### Function and method descriptions
148
149 Start descriptions in the functions and methods sections with "Returns", or for booelan values, "Reports whether".
150
151 ### File paths and names
152
153 Enclose directory names, file names, and file paths in backticks, except when used in:
154
155 - Page titles
156 - Section headings (`h1`-`h6`)
157 - The `description` field in front matter
158
159 ### Miscellaneous
160
161 Other best practices:
162
163 - Introduce lists with a sentence or phrase, not directly under a heading.
164 - Do not use Hugo's `ref` or `relref` shortcodes.
165 - Prioritize current best practices over multiple options or historical information.
166 - Use short, focused code examples.
167 - Use [basic english][] where possible for a global audience.
168
169 ## Front matter fields
170
171 This site uses the front matter fields listed in the table below.
172
173 Of the four required fields, only `title` and `description` require data.
174
175 {{< code-toggle file=content/example.md fm=true >}}
176 title: The title
177 description: The description
178 categories: []
179 keywords: []
180 {{< /code-toggle >}}
181
182 If quotation marks are required, prefer single quotes to double quotes when possible.
183
184 Field|Description|Required
185 :--|:--|:--
186 `title`|The page title|:heavy_check_mark:
187 `linkTitle`|A short version of the page title|&nbsp;
188 `description`|A complete sentence describing the page|:heavy_check_mark:
189 `categories`|An array of terms in the categories taxonomy|:heavy_check_mark: [^1]
190 `keywords`|An array of keywords used to identify related content|:heavy_check_mark: [^1]
191 `publishDate`|Applicable to news items: the publication date|&nbsp;
192 `params.alt_title`|An alternate title: used in the "see also" panel if provided|&nbsp;
193 `params.functions_and_methods.aliases`|Applicable to function and method pages: an array of alias names|&nbsp;
194 `params.functions_and_methods.returnType`|Applicable to function and method pages: the data type returned|&nbsp;
195 `params.functions_and_methods.signatures`|Applicable to function and method pages: an array of signatures|&nbsp;
196 `params.hide_in_this_section`|Whether to hide the "in this section" panel|&nbsp;
197 `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|&nbsp;
198 `params.minversion`|Applicable to the quick start page: the minimum Hugo version required|&nbsp;
199 `params.permalink`|Reserved for use by the news content adapter|&nbsp;
200 `params.reference`|Applicable to glossary entries: a URL for additional information|&nbsp;
201 `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.|&nbsp;
202 `params.show_publish_date`|Whether to show the `publishDate` when rendering the page|&nbsp;
203 `weight`|The page weight|&nbsp;
204 `aliases`|Previous URLs used to access this page|&nbsp;
205 `expirydate`|The expiration date|&nbsp;
206
207 ## Related content
208
209 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.
210
211 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:
212
213 {{< code-toggle file=hugo >}}
214 title = 'Long descriptive title'
215 linkTitle = 'Short title'
216 [params]
217 alt_title = 'Whatever you want'
218 {{< /code-toggle >}}
219
220 Use of the alternate title is limited to the "See also" sidebar.
221
222 > [!NOTE]
223 > Think carefully before setting the `alt_title`. Use it only when necessary.
224
225 ## Code examples
226
227 With examples of template code:
228
229 - Indent with two spaces.
230 - Insert a space after an opening action delimiter.
231 - Insert a space before a closing action delimiter.
232 - 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.
233
234 ````md {file="content/example.md"}
235 ```go-html-template
236 {{ if eq $foo $bar }}
237 {{ fmt.Printf "%s is %s" $foo $bar }}
238 {{ end }}
239 ```
240 ````
241
242 ### Fenced code blocks
243
244 The code block render hook performs several language substitutions:
245
246 Given language|Substitution|Reason
247 :--|:--|:--
248 `html`, `gotmpl`|`go-html-template`|Consistent rendering
249 `bash`, `ksh`, `sh`, `shell`, `zsh`|`text`|Avoid highlighting quirks
250 `md`, `mkd`|`text`|Avoid highlighting quirks
251 `tree`|`text`|There isn't a `tree` lexer
252
253 Set the language to `go-html-template` when including template examples:
254
255 ````md {file="content/example.md"}
256 ```go-html-template
257 {{ if eq $foo "bar" }}
258 {{ print "foo is bar" }}
259 {{ end }}
260 ```
261 ````
262
263 Set the language to `md` when including Markdown examples:
264
265 ````md {file="content/example.md"}
266 ```md
267 This is **bold** text.
268 ```
269 ````
270
271 Set the language to `sh` when including command line examples:
272
273 ````md {file="content/example.md"}
274 ```sh
275 hugo server -D
276 ```
277 ````
278
279 Set the language to `tree` when documenting the output of the `tree` command:
280
281 ````md {file="content/example.md"}
282 ```tree
283 assets/
284 └── images/
285 └── sunset.jpg
286 ```
287 ````
288
289 To include a file name header and copy-to-clipboard button:
290
291 ````md {file="content/example.md"}
292 ```go-html-template {file="layouts/_partials/foo.html" copy=true}
293 {{ if eq $foo "bar" }}
294 {{ print "foo is bar" }}
295 {{ end }}
296 ```
297 ````
298
299 To wrap the code block within an initially-opened `details` element using a non-default summary:
300
301 ````md {file="content/example.md"}
302 ```go-html-template {details=true open=true summary="layouts/_partials/foo.html" copy=true}
303 {{ if eq $foo "bar" }}
304 {{ print "foo is bar" }}
305 {{ end }}
306 ```
307 ````
308
309 Whitespace trimming is enabled by default. To override this behavior and preserve leading and trailing whitespace:
310
311 ````md {file="content/example.md"}
312 ```go-html-template {trim=false}
313
314 {{ if eq $foo "bar" }}
315 {{ print "foo is bar" }}
316 {{ end }}
317
318 ```
319 ````
320
321 ### Shortcode calls
322
323 Use this syntax to escape the call within examples:
324
325 ```md {file="content/example.md"}
326 {{</*/* foo */*/>}}
327 {{%/*/* foo */*/%}}
328 ```
329
330 ### Project configuration
331
332 Use the [code-toggle shortcode](#code-toggle) to include project configuration examples:
333
334 ```md {file="content/example.md"}
335 {{</* code-toggle file=hugo */>}}
336 baseURL = 'https://example.org/'
337 locale = 'en-US'
338 title = 'My Site'
339 {{</* /code-toggle */>}}
340 ```
341
342 ### Front matter
343
344 Use the [code-toggle shortcode](#code-toggle) to include front matter example, setting the `fm` attribute to `true`:
345
346 ```md {file="content/example.md"}
347 {{</* code-toggle file=content/posts/my-first-post.md fm=true */>}}
348 title = 'My first post'
349 date = 2023-11-09T12:56:07-08:00
350 draft = false
351 {{</* /code-toggle */>}}
352 ```
353
354 ## Callouts
355
356 Use callouts (admonitions) to visually emphasize important information.
357
358 There are five callout types: `note`, `important`, `tip`, `warning`, and `caution`. These are the usage statistic as of 10 Jun 2026, including usage on this page:
359
360 - note (302)
361 - tip (5)
362 - important (7)
363 - warning (7)
364 - caution (5)
365
366 The predominant use of the `note` callout type is a historical artifact; the previous theme only provided a `note` shortcode, so the callouts were generic.
367
368 In the examples below, the callout type (e.g., `note`, `warning`) is case-insensitive.
369
370 ```md {file="content/example.md"}
371 > [!NOTE]
372 > Useful information that users should know, even when skimming content.
373 ```
374
375 > [!NOTE]
376 > Useful information that users should know, even when skimming content.
377
378 ```md {file="content/example.md"}
379 > [!IMPORTANT]
380 > Key information users need to know to achieve their goal.
381 ```
382
383 > [!IMPORTANT]
384 > Key information users need to know to achieve their goal.
385
386 ```md {file="content/example.md"}
387 > [!TIP]
388 > Helpful advice for doing things better or more easily.
389 ```
390
391 > [!TIP]
392 > Helpful advice for doing things better or more easily.
393
394 ```md {file="content/example.md"}
395 > [!WARNING]
396 > Urgent info that needs immediate user attention to avoid problems.
397 ```
398
399 > [!WARNING]
400 > Urgent info that needs immediate user attention to avoid problems.
401
402 ```md {file="content/example.md"}
403 > [!CAUTION]
404 > Advises about risks or negative outcomes of certain actions.
405 ```
406
407 > [!CAUTION]
408 > Advises about risks or negative outcomes of certain actions.
409
410 ## Shortcodes
411
412 These shortcodes are commonly used throughout the documentation. Other shortcodes are available for specialized use.
413
414 ### code-toggle
415
416 Use the `code-toggle` shortcode to display examples of project configuration, front matter, or data files. This shortcode takes these arguments:
417
418 `config`
419 : (`string`) The section of `hugo.Data.docs.config` to render.
420
421 `copy`
422 : (`bool`) Whether to display a copy-to-clipboard button. Default is `false`.
423
424 `datakey`
425 : (`string`) The section of `hugo.Data.docs` to render.
426
427 `file`
428 : (`string`) The file name to display above the rendered code. Omit the file extension for project configuration examples.
429
430 `fm`
431 : (`bool`) Whether to render the code as front matter. Default is `false`.
432
433 `skipHeader`
434 : (`bool`) Whether to omit top-level key(s) when rendering a section of `hugo.Data.docs.config`.
435
436 ```md {file="content/example.md"}
437 {{</* code-toggle file=hugo copy=true */>}}
438 baseURL = 'https://example.org/'
439 locale = 'en-US'
440 title = 'My Site'
441 {{</* /code-toggle */>}}
442 ```
443
444 ### deprecated-in
445
446 Use the `deprecated-in` shortcode to indicate that a feature is deprecated:
447
448 ```md
449 {{</* deprecated-in 0.144.0 /*/>}}
450 ```
451
452 You can also include details:
453
454 ```md
455 {{</* deprecated-in 0.144.0 */>}}
456 Use the [`hugo.IsServer`](/docs/reference/functions/hugo/isserver/) function instead.
457 {{</* /deprecated-in */>}}
458 ```
459
460 ### eturl
461
462 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).
463
464 ```md {file="content/example.md"}
465 This is a link to the [embedded alias template][].
466
467 [embedded alias template]: <{{%/* eturl alias */%}}>
468 ```
469
470 ### glossary-term
471
472 Use the `glossary-term` shortcode to insert the definition of the given glossary term.
473
474 ```md {file="content/example.md"}
475 {{%/* glossary-term scalar */%}}
476 ```
477
478 ### include
479
480 Use the `include` shortcode to include content from another page.
481
482 ```md {file="content/example.md"}
483 {{%/* include "_common/glob-patterns.md" */%}}
484 ```
485
486 ### new-in
487
488 Use the `new-in` shortcode to indicate a new feature:
489
490 ```md {file="content/example.md"}
491 {{</* new-in 0.144.0 /*/>}}
492 ```
493
494 You can also include details:
495
496 ```md {file="content/example.md"}
497 {{</* new-in 0.144.0 */>}}
498 This is a new feature.
499 {{</* /new-in */>}}
500 ```
501
502 ## New features
503
504 Use the [new-in](#new-in) shortcode to indicate a new feature.
505
506 The new-in shortcode will trigger 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 this shortcode call. See [details][].
507
508 ## Deprecated features
509
510 Use the [deprecated-in](#deprecated-in) shortcode to indicate that a feature is deprecated.
511
512 The deprecated-in shortcode will trigger 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 this shortcode call and the associated content. See [details][].
513
514 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:
515
516 ```yaml
517 expiryDate: 2028-03-03 # deprecated 2026-03-03 in v0.157.0
518 ```
519
520 ## GitHub workflow
521
522 > [!NOTE]
523 > This section assumes that you have a working knowledge of Git and GitHub, and are comfortable working on the command line.
524
525 Use this workflow to create and submit pull requests.
526
527 Step 1
528 : Fork the [documentation repository][].
529
530 Step 2
531 : Clone your fork.
532
533 Step 3
534 : Create a new branch with a descriptive name that includes the corresponding issue number, if any:
535
536 ```sh
537 git checkout -b restructure-foo-page-99999
538 ```
539
540 Step 4
541 : Make changes.
542
543 Step 5
544 : Build the site locally to preview your changes.
545
546 Step 6
547 : Commit your changes with a descriptive commit message:
548
549 - Provide a summary on the first line, typically 50 characters or less, followed by a blank line.
550 - 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
551 - Use imperative present tense
552 - Optionally, provide a detailed description where each line is 72 characters or less, followed by a blank line.
553 - Optionally, add one or more "Fixes" or "Closes" keywords, each on its own line, referencing the [issues][] addressed by this change.
554
555 For example:
556
557 ```sh
558 git commit -m "content: Restructure the taxonomy page
559
560 This restructures the taxonomy page by splitting topics into logical
561 sections, each with one or more examples.
562
563 Fixes #9999
564 Closes #9998"
565 ```
566
567 Step 7
568 : Push the new branch to your fork of the documentation repository.
569
570 Step 8
571 : Visit the [documentation repository][] and create a pull request (PR).
572
573 Step 9
574 : A project maintainer will review your PR and may request changes. You may delete your branch after the maintainer merges your PR.
575
576 [^1]: The field is required, but its data is not.
577
578 [ATX]: https://spec.commonmark.org/current/#atx-headings
579 [Glossary]: /quick-reference/glossary/
580 [basic english]: https://simple.wikipedia.org/wiki/Basic_English
581 [collapsed link references]: https://discourse.gohugo.io/t/55714
582 [details]: https://github.com/gohugoio/hugoDocs/blob/master/layouts/_partials/layouts/blocks/feature-state.html
583 [developer documentation style guide]: https://developers.google.com/style
584 [documentation repository]: https://github.com/gohugoio/hugoDocs/
585 [fenced code blocks]: https://spec.commonmark.org/current/#fenced-code-blocks
586 [indented code blocks]: https://spec.commonmark.org/current/#indented-code-blocks
587 [inline links]: https://discourse.gohugo.io/t/55714
588 [issues]: https://github.com/gohugoio/hugoDocs/issues
589 [list items]: https://spec.commonmark.org/current/#list-items
590 [project repository]: https://github.com/gohugoio/hugo
591 [raw HTML]: https://spec.commonmark.org/current/#raw-html
592 [related content]: /content-management/related-content/
593 [setext]: https://spec.commonmark.org/current/#setext-heading