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