hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

documentation.md (12533B)

    1 ---
    2 title: Contribute to the Hugo Docs
    3 linktitle: Documentation
    4 description: Documentation is an integral part of any open source project. The Hugo docs are as much a work in progress as the source it attempts to cover.
    5 date: 2017-02-01
    6 publishdate: 2017-02-01
    7 lastmod: 2017-02-01
    8 categories: [contribute]
    9 keywords: [docs,documentation,community, contribute]
   10 menu:
   11   docs:
   12     parent: "contribute"
   13     weight: 20
   14 weight: 20
   15 sections_weight: 20
   16 draft: false
   17 aliases: [/contribute/docs/]
   18 toc: true
   19 ---
   20 
   21 ## Create Your Fork
   22 
   23 It's best to make changes to the Hugo docs on your local machine to check for consistent visual styling. Make sure you've created a fork of [hugoDocs](https://github.com/gohugoio/hugoDocs) on GitHub and cloned the repository locally on your machine. For more information, you can see [GitHub's documentation on "forking"][ghforking] or follow along with [Hugo's development contribution guide][hugodev].
   24 
   25 You can then create a separate branch for your additions. Be sure to choose a descriptive branch name that best fits the type of content. The following is an example of a branch name you might use for adding a new website to the showcase:
   26 
   27 ```
   28 git checkout -b jon-doe-showcase-addition
   29 ```
   30 
   31 ## Add New Content
   32 
   33 The Hugo docs make heavy use of Hugo's [archetypes][] feature. All content sections in Hugo documentation have an assigned archetype.
   34 
   35 Adding new content to the Hugo docs follows the same pattern, regardless of the content section:
   36 
   37 ```
   38 hugo new <DOCS-SECTION>/<new-content-lowercase>.md
   39 ```
   40 
   41 ### Add a New Function
   42 
   43 Once you have cloned the Hugo repository, you can create a new function via the following command. Keep the file name lowercase.
   44 
   45 ```
   46 hugo new functions/newfunction.md
   47 ```
   48 
   49 The archetype for `functions` according to the Hugo docs is as follows:
   50 
   51 {{< code file="archetypes/functions.md" >}}
   52 {{< readfile file="/archetypes/functions.md">}}
   53 {{< /code >}}
   54 
   55 #### New Function Required Fields
   56 
   57 Here is a review of the front matter fields automatically generated for you using `hugo new functions/*`:
   58 
   59 ***`title`***
   60 : this will be auto-populated in all lowercase when you use `hugo new` generator.
   61 
   62 ***`linktitle`***
   63 : the function's actual casing (e.g., `replaceRE` rather than `replacere`).
   64 
   65 ***`description`***
   66 : a brief description used to populate the [Functions Quick Reference](/functions/).
   67 
   68 `categories`
   69 : currently auto-populated with 'functions` for future-proofing and portability reasons only; ignore this field.
   70 
   71 `tags`
   72 : only if you think it will help end users find other related functions
   73 
   74 `signature`
   75 : this is a signature/syntax definition for calling the function (e.g., `apply SEQUENCE FUNCTION [PARAM...]`).
   76 
   77 `workson`
   78 : acceptable values include `lists`,`taxonomies`, `terms`, `groups`, and `files`.
   79 
   80 `hugoversion`
   81 : the version of Hugo that will ship with this new function.
   82 
   83 `relatedfuncs`
   84 : other [templating functions][] you feel are related to your new function to help fellow Hugo users.
   85 
   86 `{{.Content}}`
   87 : an extended description of the new function; examples are not only welcomed but encouraged.
   88 
   89 In the body of your function, expand the short description used in the front matter. Include as many examples as possible, and leverage the Hugo docs [`code` shortcode](#add-code-blocks). If you are unable to add examples but would like to solicit help from the Hugo community, add `needsexample: true` to your front matter.
   90 
   91 ## Add Code Blocks
   92 
   93 Code blocks are crucial for providing examples of Hugo's new features to end users of the Hugo docs. Whenever possible, create examples that you think Hugo users will be able to implement in their own projects.
   94 
   95 ### Standard Syntax
   96 
   97 Across many pages on the Hugo docs, the typical triple-back-tick markdown syntax (```` ``` ````) is used. If you do not want to take the extra time to implement the following code block shortcodes, please use standard GitHub-flavored markdown. The Hugo docs use a version of [highlight.js](https://highlightjs.org/) with a specific set of languages.
   98 
   99 Your options for languages are `xml`/`html`, `go`/`golang`, `md`/`markdown`/`mkd`, `handlebars`, `apache`, `toml`, `yaml`, `json`, `css`, `asciidoc`, `ruby`, `powershell`/`ps`, `scss`, `sh`/`zsh`/`bash`/`git`, `http`/`https`, and `javascript`/`js`.
  100 
  101 ````
  102 ```
  103 <h1>Hello world!</h1>
  104 ```
  105 ````
  106 
  107 
  108 ### Code Block Shortcode
  109 
  110 The Hugo documentation comes with a very robust shortcode for adding interactive code blocks.
  111 
  112 {{% note %}}
  113 With the `code` shortcodes, *you must include triple back ticks and a language declaration*. This was done by design so that the shortcode wrappers were easily added to legacy documentation and will be that much easier to remove if needed in future versions of the Hugo docs.
  114 {{% /note %}}
  115 
  116 ### `code`
  117 
  118 `code` is the Hugo docs shortcode you'll use most often. `code` requires has only one named parameter: `file`. Here is the pattern:
  119 
  120 ```
  121 {{%/* code file="smart/file/name/with/path.html" download="download.html" copy="true" */%}}
  122 A whole bunch of coding going on up in here!
  123 {{%/* /code */%}}
  124 ```
  125 
  126 The following are the arguments passed into `code`:
  127 
  128 
  129 ***`file`***
  130 : the only *required* argument. `file` is needed for styling but also plays an important role in helping users create a mental model around Hugo's directory structure. Visually, this will be displayed as text in the top left of the code block.
  131 
  132 `download`
  133 : if omitted, this will have no effect on the rendered shortcode. When a value is added to `download`, it's used as the filename for a downloadable version of the code block.
  134 
  135 `copy`
  136 : a copy button is added automatically to all `code` shortcodes. If you want to keep the filename and styling of `code` but don't want to encourage readers to copy the code (e.g., a "Do not do" snippet in a tutorial), use `copy="false"`.
  137 
  138 #### Example `code` Input
  139 
  140 This example HTML code block tells Hugo users the following:
  141 
  142 1. This file *could* live in `layouts/_default`, as demonstrated by `layouts/_default/single.html` as the value for `file`.
  143 2. This snippet is complete enough to be downloaded and implemented in a Hugo project, as demonstrated by `download="single.html"`.
  144 
  145 ```
  146 {{</* code file="layouts/_default/single.html" download="single.html" */>}}
  147 {{ define "main" }}
  148 <main>
  149     <article>
  150         <header>
  151             <h1>{{.Title}}</h1>
  152             {{with .Params.subtitle}}
  153             <span>{{.}}</span>
  154         </header>
  155         <div>
  156             {{.Content}}
  157         </div>
  158         <aside>
  159             {{.TableOfContents}}
  160         </aside>
  161     </article>
  162 </main>
  163 {{ end }}
  164 {{</* /code */>}}
  165 ```
  166 
  167 ##### Example 'code' Display
  168 
  169 The output of this example will render to the Hugo docs as follows:
  170 
  171 {{< code file="layouts/_default/single.html" download="single.html" >}}
  172 {{ define "main" }}
  173 <main>
  174     <article>
  175         <header>
  176             <h1>{{.Title}}</h1>
  177             {{with .Params.subtitle}}
  178             <span>{{.}}</span>
  179         </header>
  180         <div>
  181             {{.Content}}
  182         </div>
  183         <aside>
  184             {{.TableOfContents}}
  185         </aside>
  186     </article>
  187 </main>
  188 {{ end }}
  189 {{< /code >}}
  190 
  191 <!-- #### Output Code Block
  192 
  193 The `output` shortcode is almost identical to the `code` shortcode but only takes and requires `file`. The purpose of `output` is to show *rendered* HTML and therefore almost always follows another basic code block *or* and instance of the `code` shortcode:
  194 
  195 ```
  196 {{%/* output file="posts/my-first-post/index.html" */%}}
  197 <h1>This is my First Hugo Blog Post</h1>
  198 <p>I am excited to be using Hugo.</p>
  199 {{%/* /output */%}}
  200 ```
  201 
  202 The preceding `output` example will render as follows to the Hugo docs:
  203 
  204 {{< output file="posts/my-first-post/index.html" >}}
  205 <h1>This is my First Hugo Blog Post</h1>
  206 <p>I am excited to be using Hugo.</p>
  207 {{< /output >}} -->
  208 
  209 ## Blockquotes
  210 
  211 Blockquotes can be added to the Hugo documentation using [typical Markdown blockquote syntax][bqsyntax]:
  212 
  213 ```
  214 > Without the threat of punishment, there is no joy in flight.
  215 ```
  216 
  217 The preceding blockquote will render as follows in the Hugo docs:
  218 
  219 > Without the threat of punishment, there is no joy in flight.
  220 
  221 However, you can add a quick and easy `<cite>` element (added on the client via JavaScript) by separating your main blockquote and the citation with a hyphen with a single space on each side:
  222 
  223 ```
  224 > Without the threat of punishment, there is no joy in flight. - [Kobo Abe](https://en.wikipedia.org/wiki/Kobo_Abe)
  225 ```
  226 
  227 Which will render as follows in the Hugo docs:
  228 
  229 > Without the threat of punishment, there is no joy in flight. - [Kobo Abe][abe]
  230 
  231 {{% note "Blockquotes `!=` Admonitions" %}}
  232 Previous versions of Hugo documentation used blockquotes to draw attention to text. This is *not* the [intended semantic use of `<blockquote>`](https://html5doctor.com/cite-and-blockquote-reloaded/). Use blockquotes when quoting. To note or warn your user of specific information, use the admonition shortcodes that follow.
  233 {{% /note %}}
  234 
  235 ## Admonitions
  236 
  237 **Admonitions** are common in technical documentation. The most popular is that seen in [reStructuredText Directives][sourceforge]. From the SourceForge documentation:
  238 
  239 > Admonitions are specially marked "topics" that can appear anywhere an ordinary body element can. They contain arbitrary body elements. Typically, an admonition is rendered as an offset block in a document, sometimes outlined or shaded, with a title matching the admonition type. - [SourceForge][sourceforge]
  240 
  241 The Hugo docs contain three admonitions: `note`, `tip`, and `warning`.
  242 
  243 ### `note` Admonition
  244 
  245 Use the `note` shortcode when you want to draw attention to information subtly. `note` is intended to be less of an interruption in content than is `warning`.
  246 
  247 #### Example `note` Input
  248 
  249 {{< code file="note-with-heading.md" >}}
  250 {{%/* note */%}}
  251 Here is a piece of information I would like to draw your **attention** to.
  252 {{%/* /note */%}}
  253 {{< /code >}}
  254 
  255 #### Example `note` Output
  256 
  257 {{< output file="note-with-heading.html" >}}
  258 {{% note %}}
  259 Here is a piece of information I would like to draw your **attention** to.
  260 {{% /note %}}
  261 {{< /output >}}
  262 
  263 #### Example `note` Display
  264 
  265 {{% note %}}
  266 Here is a piece of information I would like to draw your **attention** to.
  267 {{% /note %}}
  268 
  269 ### `tip` Admonition
  270 
  271 Use the `tip` shortcode when you want to give the reader advice. `tip`, like `note`, is intended to be less of an interruption in content than is `warning`.
  272 
  273 #### Example `tip` Input
  274 
  275 {{< code file="using-tip.md" >}}
  276 {{%/* tip */%}}
  277 Here's a bit of advice to improve your productivity with Hugo.
  278 {{%/* /tip */%}}
  279 {{< /code >}}
  280 
  281 #### Example `tip` Output
  282 
  283 {{< output file="tip-output.html" >}}
  284 {{% tip %}}
  285 Here's a bit of advice to improve your productivity with Hugo.
  286 {{% /tip %}}
  287 {{< /output >}}
  288 
  289 #### Example `tip` Display
  290 
  291 {{% tip %}}
  292 Here's a bit of advice to improve your productivity with Hugo.
  293 {{% /tip %}}
  294 
  295 ### `warning` Admonition
  296 
  297 Use the `warning` shortcode when you want to draw the user's attention to something important. A good usage example is for articulating breaking changes in Hugo versions, known bugs, or templating "gotchas."
  298 
  299 #### Example `warning` Input
  300 
  301 {{< code file="warning-admonition-input.md" >}}
  302 {{%/* warning */%}}
  303 This is a warning, which should be reserved for *important* information like breaking changes.
  304 {{%/* /warning */%}}
  305 {{< /code >}}
  306 
  307 #### Example `warning` Output
  308 
  309 {{< output file="warning-admonition-output.html" >}}
  310 {{% warning %}}
  311 This is a warning, which should be reserved for *important* information like breaking changes.
  312 {{% /warning %}}
  313 {{< /output >}}
  314 
  315 #### Example `warning` Display
  316 
  317 {{% warning %}}
  318 This is a warning, which should be reserved for *important* information like breaking changes.
  319 {{% /warning %}}
  320 
  321 {{% note "Pull Requests and Branches" %}}
  322 Similar to [contributing to Hugo development](/contribute/development/), the Hugo team expects you to create a separate branch/fork when you make your contributions to the Hugo docs.
  323 {{% /note %}}
  324 
  325 [abe]: https://en.wikipedia.org/wiki/Kobo_Abe
  326 [archetypes]: /content-management/archetypes/
  327 [bqsyntax]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#blockquotes
  328 [charcount]: https://www.lettercount.com/
  329 [`docs/static/images/showcase/`]: https://github.com/gohugoio/hugo/tree/master/docs/static/images/showcase/
  330 [ghforking]: https://help.github.com/articles/fork-a-repo/
  331 [hugodev]: /contribute/development/
  332 [shortcodeparams]: content-management/shortcodes/#shortcodes-without-markdown
  333 [sourceforge]: https://docutils.sourceforge.io/docs/ref/rst/directives.html#admonitions
  334 [templating function]: /functions/