Remove opinionated code blocks (Third round)

Closes rdwatters/hugo-docs-concept#105
This commit is contained in:
Ryan Watters committed 2017-04-30 17:16:40 -05:00
1 parent bc9a649195
commit 71471f13ce
12 files changed
+67 -43

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ workson: [menus]
hugoversion: hugoversion:
relatedfuncs: [] relatedfuncs: []
deprecated: false deprecated: false
draft: false draft: true
aliases: [] aliases: []
needsexamples: true needsexamples: true
--- ---
+1 -1
View File
@@ -15,7 +15,7 @@ hugoversion:
relatedfuncs: [] relatedfuncs: []
deprecated: false deprecated: false
toc: false toc: false
draft: false draft: true
aliases: [] aliases: []
needsexamples: true needsexamples: true
--- ---
+2 -1
View File
@@ -14,8 +14,9 @@ workson: [menus]
hugoversion: hugoversion:
relatedfuncs: [] relatedfuncs: []
deprecated: false deprecated: false
draft: false draft: true
aliases: [] aliases: []
needsexample: true
--- ---
Used in [menu templates](/templates/menu-templates/). Used in [menu templates](/templates/menu-templates/).
+4 -4
View File
@@ -5,7 +5,7 @@ description: Returns the current local time as a [`time.Time`]
godocref: https://godoc.org/time#Time godocref: https://godoc.org/time#Time
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2017-04-30
categories: [functions] categories: [functions]
tags: [dates,time] tags: [dates,time]
ns: ns:
@@ -23,7 +23,7 @@ needsexamples: true
For example, building your site on June 24, 2017 with the following templating: For example, building your site on June 24, 2017 with the following templating:
```html ```html
<div class="copyright"> <div>
<small>&copy; {{ now.Format "2006"}}</small> <small>&copy; {{ now.Format "2006"}}</small>
</div> </div>
``` ```
@@ -31,12 +31,12 @@ For example, building your site on June 24, 2017 with the following templating:
Which will produce the following: Which will produce the following:
```html ```html
<div class="copyright"> <div>
<small>&copy; 2017</small> <small>&copy; 2017</small>
</div> </div>
``` ```
The above example also uses the [`.Format` function](/functions/format), which page includes a full listing of date formatting using Golang's layout string. The above example uses the [`.Format` function](/functions/format), which page includes a full listing of date formatting using Golang's layout string.
{{% note %}} {{% note %}}
Older Hugo themes may use the deprecated `.Now` (uppercase). Be sure to use the lowercase `.now` in your templating. Older Hugo themes may use the deprecated `.Now` (uppercase). Be sure to use the lowercase `.now` in your templating.
+10 -5
View File
@@ -5,31 +5,36 @@ description: Calls page or site variables into your template.
godocref: godocref:
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2017-04-30
tags: [] tags: ["front matter"]
categories: [functions] categories: [functions]
toc: toc:
ns: ns:
signature: ["Param KEY"] signature: ["Param KEY"]
workson: [] workson: []
hugoversion: hugoversion:
relatedfuncs: [] relatedfuncs: [default]
deprecated: false deprecated: false
draft: false draft: false
aliases: [] aliases: []
wip: true
--- ---
In Hugo, you can declare [site-wide params][sitevars] (i.e. in your [configuration][]), as well as params for [individual pages][pagevars]. In Hugo, you can declare [site-wide params][sitevars] (i.e. in your [configuration][]), as well as params for [individual pages][pagevars].
A common use case is to have a general value for the site and a more specific value for some of the pages (e.g., an image). A common use case is to have a general value for the site and a more specific value for some of the pages (e.g., an image).
You can use the `.Param` method to call these values into your template: You can use the `.Param` method to call these values into your template. The following will first look for an `image` param in a specific content's [front matter][]. If not found, Hugo will look for an `image` param in your site's configuration:
``` ```
$.Param "image" $.Param "image"
``` ```
{{% note %}}
The `Param` method may not consider empty strings in a content's front matter as "not found." If you are setting preconfigured front matter fields to empty strings using Hugo's archetypes, it may be best to use the [`default` function](/functions/default/) instead of `Param`. See the [related issue on GitHub](https://github.com/spf13/hugo/issues/3366).
{{% /note %}}
[configuration]: /getting-started/configuration/ [configuration]: /getting-started/configuration/
[front matter]: /content-management/front-matter/
[pagevars]: /variables/page/ [pagevars]: /variables/page/
[sitevars]: /variables/site/ [sitevars]: /variables/site/
+3 -3
View File
@@ -5,14 +5,14 @@ description: Strips any HTML and returns the plain text version of the provided
godocref: godocref:
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2017-04-30
categories: [functions] categories: [functions]
tags: [strings] tags: [strings]
ns: ns:
signature: ["plainify INPUT"] signature: ["plainify INPUT"]
workson: [] workson: []
hugoversion: hugoversion:
relatedfuncs: [jsonify] relatedfuncs: [jsonify,]
deprecated: false deprecated: false
aliases: [] aliases: []
--- ---
@@ -23,7 +23,7 @@ aliases: []
{{ "<b>BatMan</b>" | plainify }} → "BatMan" {{ "<b>BatMan</b>" | plainify }} → "BatMan"
``` ```
See also the [`.PlainWords`, `.Plain`, and `.RawContent` page variables][pagevars]. See also the `.PlainWords`, `.Plain`, and `.RawContent` [page variables][pagevars].
[pagevars]: /variables/page/ [pagevars]: /variables/page/
+2 -2
View File
@@ -5,7 +5,7 @@ description: Reads a file from disk relative to the current project working dire
godocref: godocref:
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2017-04-30
categories: [functions] categories: [functions]
tags: [files] tags: [files]
ns: ns:
@@ -21,7 +21,7 @@ aliases: []
So, if you have a file with the name `README.txt` in the root of your project with the content `Hugo Rocks!`: So, if you have a file with the name `README.txt` in the root of your project with the content `Hugo Rocks!`:
``` ```html
{{readFile "README.txt"}} → "Hugo Rocks!" {{readFile "README.txt"}} → "Hugo Rocks!"
``` ```
+6 -3
View File
@@ -35,7 +35,8 @@ The following is an example of a sidebar partial that may be used in conjunction
{{% code file="layouts/partials/bad-url-sidebar-menu.html" copy="false" %}} {{% code file="layouts/partials/bad-url-sidebar-menu.html" copy="false" %}}
```html ```html
<ul class="sidebar-menu"> <!-- This unordered list may be part of a sidebar menu -->
<ul>
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
<li><a href="{{ .URL }}">{{ .Name }}</a></li> <li><a href="{{ .URL }}">{{ .Name }}</a></li>
{{ end }} {{ end }}
@@ -47,7 +48,8 @@ This partial would produce the following HTML output:
{{% output file="bad-url-sidebar-menu-output.html" %}} {{% output file="bad-url-sidebar-menu-output.html" %}}
```html ```html
<ul class="sidebar-menu"> <!-- This unordered list may be part of a sidebar menu -->
<ul>
<li><a href="#ZgotmplZ">IRC: #golang at freenode</a></li> <li><a href="#ZgotmplZ">IRC: #golang at freenode</a></li>
</ul> </ul>
``` ```
@@ -57,7 +59,8 @@ The odd output can be remedied by adding ` | safeURL` to our `.Title` page varia
{{% code file="layouts/partials/correct-url-sidebar-menu.html" copy="false" %}} {{% code file="layouts/partials/correct-url-sidebar-menu.html" copy="false" %}}
```html ```html
<ul class="sidebar-menu"> <!-- This unordered list may be part of a sidebar menu -->
<ul>
<li><a href="{{ .URL | safeURL }}">{{ .Name }}</a></li> <li><a href="{{ .URL | safeURL }}">{{ .Name }}</a></li>
</ul> </ul>
``` ```
+10 -6
View File
@@ -5,14 +5,14 @@ description: Returns a random permutation of a given array or slice.
godocref: godocref:
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2017-04-30
tags: [ordering] tags: [ordering]
categories: [functions] categories: [functions]
ns: ns:
signature: ["shuffle COLLECTION"] signature: ["shuffle COLLECTION"]
workson: [] workson: []
hugoversion: hugoversion:
relatedfuncs: [] relatedfuncs: [seq]
deprecated: false deprecated: false
draft: false draft: false
aliases: [] aliases: []
@@ -23,8 +23,10 @@ needsexamples: true
{{% code file="shuffle-input.html" %}} {{% code file="shuffle-input.html" %}}
```html ```html
<div class="shuffle-sequence">{{ shuffle (seq 1 5) }}</div> <!-- Shuffled sequence = -->
<div class="shuffle-slice">{{ shuffle (slice "foo" "bar" "buzz") }}</div> <div>{{ shuffle (seq 1 5) }}</div>
<!-- Shuffled slice = -->
<div>{{ shuffle (slice "foo" "bar" "buzz") }}</div>
``` ```
{{% /code %}} {{% /code %}}
@@ -32,8 +34,10 @@ This example would return the following:
{{% output file="shuffle-output.html" %}} {{% output file="shuffle-output.html" %}}
```html ```html
<div class="shuffle-seq">2 5 3 1 4</div> <!-- Shuffled sequence = -->
<div class="shuffle-slice">buzz foo bar</div> <div>2 5 3 1 4</div>
<!-- Shuffled slice = -->
<div>buzz foo bar</div>
``` ```
{{% /output %}} {{% /output %}}
+25 -14
View File
@@ -34,16 +34,21 @@ The following might be used as a partial within a [single page template][singlet
{{% code file="layouts/partials/content-header.html" download="content-header.html" %}} {{% code file="layouts/partials/content-header.html" download="content-header.html" %}}
```html ```html
<header class="content-header"> <header>
<h1>{{.Title}}</h1> <h1>{{.Title}}</h1>
{{ with .Params.location }} {{ with .Params.location }}
<div class="location"><a href="/locations/{{ . | urlize}}">{{.}}</a></div> <div><a href="/locations/{{ . | urlize}}">{{.}}</a></div>
{{ end }}
<!-- Creates a list of tags for the content and links to each of their pages -->
{{ with .Params.tags }}
<ul>
{{range .}}
<li>
<a href="/tags/{{ . | urlize }}">{{ . }}</a>
</li>
{{end}}
</ul>
{{ end }} {{ end }}
<div class="tags">
{{range .Params.tags}}
<a href="/tags/{{ . | urlize }}" class="tag">{{ . }}</a><br>
{{end}}
</div>
</header> </header>
``` ```
{{% /code %}} {{% /code %}}
@@ -52,14 +57,20 @@ The preceding partial would then output to the rendered page as follows, assumin
{{% output file="/blog/greatest-city/index.html" %}} {{% output file="/blog/greatest-city/index.html" %}}
```html ```html
<header class="content-header"> <header>
<h1>The World's Greatest City</h1> <h1>The World's Greatest City</h1>
<div class="location"><a href="/locations/chicago-il/">Chicago IL</a></div> <div><a href="/locations/chicago-il/">Chicago IL</a></div>
<div class="tags"> <ul>
<a href="/tags/pizza" class="tag">pizza</a> <li>
<a href="/tags/beer" class="tag">beer</a> <a href="/tags/pizza">pizza</a>
<a href="/tags/hot-dogs" class="tag">hot dogs</a> </li>
</div> <li>
<a href="/tags/beer">beer</a>
</li>
<li>
<a href="/tags/hot-dogs">hot dogs</a>
</li>
</ul>
</header> </header>
``` ```
{{% /output %}} {{% /output %}}
+1 -1
View File
@@ -5,7 +5,7 @@ description: Filters an array to only the elements containing a matching value f
godocref: godocref:
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2017-04-30
categories: [functions] categories: [functions]
tags: [filtering] tags: [filtering]
ns: ns:
+2 -2
View File
@@ -16,9 +16,9 @@ relatedfuncs: []
deprecated: false deprecated: false
--- ---
An alternative way of writing the "`if`" and then referencing the same value is to use `with` instead. `with` rebinds the context (`.`) within its scope and skips the block if the variable is absent. An alternative way of writing an `if` statement and then referencing the same value is to use `with` instead. `with` rebinds the context (`.`) within its scope and skips the block if the variable is absent or unset.
The following example checks for a [user-defined site variable](/variables/site/) defined as `twitteruser` in your [site configuration](/getting-started/configuration/). If the key-value is not set, the following will render nothing: The following example checks for a [user-defined site variable](/variables/site/) called `twitteruser`. If the key-value is not set, the following will render nothing:
{{% code file="layouts/partials/twitter.html" %}} {{% code file="layouts/partials/twitter.html" %}}
```html ```html