Code Toggle block added to doc site final batch

Templates 
Variables 
This commit is contained in:
Regis Philibert 2018-04-12 09:28:50 -04:00 committed by Bjørn Erik Pedersen
parent 4d41079684
commit f9a5dc59b7
7 changed files with 23 additions and 38 deletions

View File

@ -95,16 +95,16 @@ Discover a new favorite bass player? Just add another `.toml` file in the same d
## Example: Accessing Named Values in a Data File
Assume you have the following YAML structure in your `User0123.yml` data file located directly in `data/`:
Assume you have the following data structure in your `User0123.[yml|toml|json]` data file located directly in `data/`:
```
{{< code-toggle file="User0123" >}}
Name: User0123
"Short Description": "He is a **jolly good** fellow."
Achievements:
- "Can create a Key, Value list from Data File"
- "Learns Hugo"
- "Reads documentation"
```
{{</ code-toggle >}}
You can use the following code to render the `Short Description` in your layout::

View File

@ -33,13 +33,9 @@ Hugo ships with internal templates for Google Analytics tracking, including both
Provide your tracking id in your configuration file:
```
{{< code-toggle file="config" >}}
googleAnalytics = "UA-123-45"
```
```
googleAnalytics: "UA-123-45"
```
{{</ code-toggle >}}
### Use the Google Analytics Template
@ -62,13 +58,9 @@ Hugo also ships with an internal template for [Disqus comments][disqus], a popul
To use Hugo's Disqus template, you first need to set a single value in your site's `config.toml` or `config.yml`:
```
{{< code-toggle file="config" >}}
disqusShortname = "yourdiscussshortname"
```
```
disqusShortname: "yourdiscussshortname"
```
{{</ code-toggle >}}
You also have the option to set the following in the front matter for a given piece of content:

View File

@ -458,7 +458,7 @@ You can arbitrarily define as many site-level parameters as you want in your [si
For instance, you might declare the following:
{{< code file="config.yaml" >}}
{{< code-toggle file="config" >}}
params:
copyrighthtml: "Copyright &#xA9; 2017 John Doe. All Rights Reserved."
twitteruser: "spf13"

View File

@ -94,16 +94,16 @@ In the above, the menu item is marked as active if on the current section's list
## Site Config menus
The above is all that's needed. But if you want custom menu items, e.g. changing weight, name, or link title attribute, you can define them manually in the site config, i.e. `config.toml`:
The above is all that's needed. But if you want custom menu items, e.g. changing weight, name, or link title attribute, you can define them manually in the site config file:
```
{{< code-toggle file="config" >}}
[[menu.main]]
name = "This is the blog section"
title = "blog section"
weight = -110
identifier = "blog"
url = "/blog/"
```
{{</ code-toggle >}}
{{% note %}}
The `identifier` *must* match the section name.

View File

@ -37,13 +37,13 @@ This is the full set of built-in media types in Hugo:
To add or modify a media type, define it in a `mediaTypes` section in your [site configuration][config], either for all sites or for a given language.
```
{{< code-toggle file="config" >}}
[mediaTypes]
[mediaTypes."text/enriched"]
suffix = "enr"
[mediaTypes."text/html"]
suffix = "asp"
```
{{</ code-toggle >}}
The above example adds one new media type, `text/enriched`, and changes the suffix for the built-in `text/html` media type.
@ -76,13 +76,13 @@ This is the full set of Hugo's built-in output formats:
To add or modify an output format, define it in an `outputFormats` section in your site's [configuration file](/getting-started/configuration/), either for all sites or for a given language.
```
{{< code-toggle file="config" >}}
[outputFormats.MyEnrichedFormat]
mediaType = "text/enriched"
baseName = "myindex"
isPlainText = true
protocol = "bep://"
```
{{</ code-toggle >}}
The above example is fictional, but if used for the homepage on a site with `baseURL` `https://example.org`, it will produce a plain text homepage with the URL `bep://example.org/myindex.enr`.
@ -143,21 +143,14 @@ This can be changed by defining an `outputs` list of output formats in either
the `Page` front matter or in the site configuration (either for all sites or
per language).
Example from site `config.toml`:
Example from site config file`:
```
{{< code-toggle file="config" >}}
[outputs]
home = ["HTML", "AMP", "RSS"]
page = ["HTML"]
```
{{</ code-toggle >}}
Example from site `config.yml`:
```
outputs:
home: ["HTML", "AMP", "RSS"]
page: ["HTML"]
```
Note that in the above examples, the *output formats* for `section`,
`taxonomyTerm` and `taxonomy` will stay at their default value `["HTML",

View File

@ -63,12 +63,12 @@ on render. Please don't include this in the template as it's not valid HTML.
Defaults for `<changefreq>`, `<priority>` and `filename` values can be set in the site's config file, e.g.:
```
{{< code-toggle file="config" >}}
[sitemap]
changefreq = "monthly"
priority = 0.5
filename = "sitemap.xml"
```
{{</ code-toggle >}}
The same fields can be specified in an individual content file's front matter in order to override the value assigned to that piece of content at render time.

View File

@ -109,15 +109,15 @@ The following is a list of site-level (aka "global") variables. Many of these va
### Example: `.Site.Params`
The following `config.toml` defines a site-wide param for `description`:
The following `config.[yaml|toml|json]` defines a site-wide param for `description`:
```
{{< code-toggle file="config" >}}
baseURL = "https://yoursite.example.com/"
[params]
description = "Tesla's Awesome Hugo Site"
author = "Nikola Tesla"
```
{{</ code-toggle >}}
You can use `.Site.Params` in a [partial template](/templates/partials/) to call the default site description: