github.com/rabbouni145/gg@v0.47.1/docs/content/en/contribute/documentation.md (about)

     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](#adding-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 all 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  ### Code Block Shortcode
   108  
   109  The Hugo documentation comes with a very robust shortcode for adding interactive code blocks.
   110  
   111  {{% note %}}
   112  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.
   113  {{% /note %}}
   114  
   115  ### `code`
   116  
   117  `code` is the Hugo docs shortcode you'll use most often. `code` requires has only one named parameter: `file`. Here is the pattern:
   118  
   119  ```
   120  {{%/* code file="smart/file/name/with/path.html" download="download.html" copy="true" */%}}
   121  ```
   122  A whole bunch of coding going on up in here!
   123  ```
   124  {{%/* /code */%}}
   125  ```
   126  
   127  The following are the arguments passed into `code`:
   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="post/my-first-post/index.html" */%}}
   197  ```
   198  <h1>This is my First Hugo Blog Post</h1>
   199  <p>I am excited to be using Hugo.</p>
   200  ```
   201  {{%/* /output */%}}
   202  ```
   203  
   204  The preceding `output` example will render as follows to the Hugo docs:
   205  
   206  {{< output file="post/my-first-post/index.html" >}}
   207  <h1>This is my First Hugo Blog Post</h1>
   208  <p>I am excited to be using Hugo.</p>
   209  {{< /output >}} -->
   210  
   211  ## Blockquotes
   212  
   213  Blockquotes can be added to the Hugo documentation using [typical Markdown blockquote syntax][bqsyntax]:
   214  
   215  ```
   216  > Without the threat of punishment, there is no joy in flight.
   217  ```
   218  
   219  The preceding blockquote will render as follows in the Hugo docs:
   220  
   221  > Without the threat of punishment, there is no joy in flight.
   222  
   223  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:
   224  
   225  ```
   226  > Without the threat of punishment, there is no joy in flight. - [Kobo Abe](https://en.wikipedia.org/wiki/Kobo_Abe)
   227  ```
   228  
   229  Which will render as follows in the Hugo docs:
   230  
   231  > Without the threat of punishment, there is no joy in flight. - [Kobo Abe][abe]
   232  
   233  {{% note "Blockquotes `!=` Admonitions" %}}
   234  Previous versions of Hugo documentation used blockquotes to draw attention to text. This is *not* the [intended semantic use of `<blockquote>`](http://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.
   235  {{% /note %}}
   236  
   237  ## Admonitions
   238  
   239  **Admonitions** are common in technical documentation. The most popular is that seen in [reStructuredText Directives][sourceforge]. From the SourceForge documentation:
   240  
   241  > 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]
   242  
   243  The Hugo docs contain three admonitions: `note`, `tip`, and `warning`.
   244  
   245  ### `note` Admonition
   246  
   247  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`.
   248  
   249  #### Example `note` Input
   250  
   251  {{< code file="note-with-heading.md" >}}
   252  {{%/* note */%}}
   253  Here is a piece of information I would like to draw your **attention** to.
   254  {{%/* /note */%}}
   255  {{< /code >}}
   256  
   257  #### Example `note` Output
   258  
   259  {{< output file="note-with-heading.html" >}}
   260  {{% note %}}
   261  Here is a piece of information I would like to draw your **attention** to.
   262  {{% /note %}}
   263  {{< /output >}}
   264  
   265  #### Example `note` Display
   266  
   267  {{% note %}}
   268  Here is a piece of information I would like to draw your **attention** to.
   269  {{% /note %}}
   270  
   271  ### `tip` Admonition
   272  
   273  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`.
   274  
   275  #### Example `tip` Input
   276  
   277  {{< code file="using-tip.md" >}}
   278  {{%/* tip */%}}
   279  Here's a bit of advice to improve your productivity with Hugo.
   280  {{%/* /tip */%}}
   281  {{< /code >}}
   282  
   283  #### Example `tip` Output
   284  
   285  {{< output file="tip-output.html" >}}
   286  {{% tip %}}
   287  Here's a bit of advice to improve your productivity with Hugo.
   288  {{% /tip %}}
   289  {{< /output >}}
   290  
   291  #### Example `tip` Display
   292  
   293  {{% tip %}}
   294  Here's a bit of advice to improve your productivity with Hugo.
   295  {{% /tip %}}
   296  
   297  ### `warning` Admonition
   298  
   299  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."
   300  
   301  #### Example `warning` Input
   302  
   303  {{< code file="warning-admonition-input.md" >}}
   304  {{%/* warning */%}}
   305  This is a warning, which should be reserved for *important* information like breaking changes.
   306  {{%/* /warning */%}}
   307  {{< /code >}}
   308  
   309  #### Example `warning` Output
   310  
   311  {{< output file="warning-admonition-output.html" >}}
   312  {{% warning %}}
   313  This is a warning, which should be reserved for *important* information like breaking changes.
   314  {{% /warning %}}
   315  {{< /output >}}
   316  
   317  #### Example `warning` Display
   318  
   319  {{% warning %}}
   320  This is a warning, which should be reserved for *important* information like breaking changes.
   321  {{% /warning %}}
   322  
   323  {{% note "Pull Requests and Branches" %}}
   324  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.
   325  {{% /note %}}
   326  
   327  [abe]: https://en.wikipedia.org/wiki/Kobo_Abe
   328  [archetypes]: /content-management/archetypes/
   329  [bqsyntax]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#blockquotes
   330  [charcount]: http://www.lettercount.com/
   331  [`docs/static/images/showcase/`]: https://github.com/gohugoio/hugo/tree/master/docs/static/images/showcase/
   332  [ghforking]: https://help.github.com/articles/fork-a-repo/
   333  [hugodev]: /contribute/development/
   334  [shortcodeparams]: content-management/shortcodes/#shortcodes-without-markdown
   335  [sourceforge]: http://docutils.sourceforge.net/docs/ref/rst/directives.html#admonitions
   336  [templating function]: /functions/