mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 14:40:43 +03:00
Merge commit 'efa74c5c6e
'
This commit is contained in:
commit
0a9172672a
74 changed files with 112 additions and 156 deletions
|
@ -18,8 +18,7 @@ deprecated: false
|
|||
aliases: []
|
||||
---
|
||||
|
||||
|
||||
By default all matches will be included. The number of matches can be limitted with an optional third parameter.
|
||||
By default all matches will be included. The number of matches can be limited with an optional third parameter.
|
||||
|
||||
The example below returns a list of all second level headers (`<h2>`) in the content:
|
||||
|
||||
|
@ -40,7 +39,6 @@ Hugo uses Go's [Regular Expression package](https://golang.org/pkg/regexp/), whi
|
|||
If you are just learning RegEx, or at least Go's flavor, you can practice pattern matching in the browser at <https://regex101.com/>.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
[partials]: /templates/partials/
|
||||
[`plainify`]: /functions/plainify/
|
||||
[toc]: /content-management/toc/
|
||||
|
|
|
@ -20,7 +20,7 @@ aliases: []
|
|||
|
||||
Takes a string containing the name of the variable as input. Returns
|
||||
an empty string if the variable is not set, otherwise returns the
|
||||
value of the variable.
|
||||
value of the variable.
|
||||
|
||||
```
|
||||
{{ getenv "HOME" }}
|
||||
|
|
|
@ -22,5 +22,5 @@ aliases: []
|
|||
In the result `&` becomes `&` and so on. It escapes only: `<`, `>`, `&`, `'` and `"`.
|
||||
|
||||
```
|
||||
{{ htmlEscape "Hugo & Caddy > Wordpress & Apache" }} → "Hugo & Caddy > Wordpress & Apache"
|
||||
{{ htmlEscape "Hugo & Caddy > WordPress & Apache" }} → "Hugo & Caddy > WordPress & Apache"
|
||||
```
|
||||
|
|
|
@ -19,10 +19,10 @@ deprecated: false
|
|||
aliases: []
|
||||
---
|
||||
|
||||
`htmlUnescape` returns the given string with HTML escape codes un-escaped.
|
||||
`htmlUnescape` returns the given string with HTML escape codes un-escaped.
|
||||
|
||||
Remember to pass the output of this to `safeHTML` if fully un-escaped characters are desired. Otherwise, the output will be escaped again as normal.
|
||||
|
||||
```
|
||||
{{ htmlUnescape "Hugo & Caddy > Wordpress & Apache" }} → "Hugo & Caddy > Wordpress & Apache"
|
||||
{{ htmlUnescape "Hugo & Caddy > WordPress & Apache" }} → "Hugo & Caddy > WordPress & Apache"
|
||||
```
|
||||
|
|
|
@ -20,7 +20,7 @@ deprecated: false
|
|||
draft: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
|
||||
`hugo` returns an instance that contains the following functions:
|
||||
|
||||
hugo.Generator
|
||||
|
@ -29,7 +29,7 @@ hugo.Generator
|
|||
hugo.Version
|
||||
: the current version of the Hugo binary you are using e.g. `0.63.2`
|
||||
|
||||
|
||||
|
||||
`hugo` returns an instance that contains the following functions:
|
||||
|
||||
hugo.Environment
|
||||
|
|
|
@ -38,8 +38,6 @@ The function takes multiple indices as arguments, and this can be used to get ne
|
|||
{{ index $map "c" "e" }} => 20
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Example: Load Data from a Path Based on Front Matter Params
|
||||
|
||||
Assume you want to add a `location = ""` field to your front matter for every article written in `content/vacations/`. You want to use this field to populate information about the location at the bottom of the article in your `single.html` template. You also have a directory in `data/locations/` that looks like the following:
|
||||
|
@ -93,4 +91,3 @@ Now the call will return the specific file according to the location specified i
|
|||
{{ (index .Site.Data.locations .Params.location).pop_city }}
|
||||
=> 658390
|
||||
```
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ draft: false
|
|||
aliases: []
|
||||
---
|
||||
|
||||
|
||||
```
|
||||
{{ range last 10 .Pages }}
|
||||
{{ .Render "summary" }}
|
||||
|
|
|
@ -19,8 +19,6 @@ deprecated: false
|
|||
aliases: []
|
||||
---
|
||||
|
||||
|
||||
|
||||
```
|
||||
{{ md5 "Hello world, gophers!" }}
|
||||
<!-- returns the string "b3029f756f98f79e7f1b7f1d1f0dd53b" -->
|
||||
|
|
|
@ -14,7 +14,7 @@ keywords: [strings]
|
|||
signature: ["plainify INPUT"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: [jsonify,]
|
||||
relatedfuncs: [jsonify]
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
|
@ -25,7 +25,4 @@ aliases: []
|
|||
|
||||
See also the `.PlainWords`, `.Plain`, and `.RawContent` [page variables][pagevars].
|
||||
|
||||
|
||||
[pagevars]: /variables/page/
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
title: relURL
|
||||
description: Given a string, prepends the relative URL according to a page's position in the project directory structure.
|
||||
description: Creates a baseURL-relative URL.
|
||||
godocref:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
|
|
|
@ -48,4 +48,4 @@ $indexStartingAt1 := (add $index 1)
|
|||
```
|
||||
|
||||
|
||||
[GNU's seq]: http://www.gnu.org/software/coreutils/manual/html_node/seq-invocation.html#seq-invocation
|
||||
[GNU's seq]: https://www.gnu.org/software/coreutils/manual/html_node/seq-invocation.html#seq-invocation
|
||||
|
|
|
@ -22,7 +22,7 @@ toc: false
|
|||
deprecated: false
|
||||
---
|
||||
|
||||
A template file is any file living below the `layouts` directories of either the project or any of its theme components incudling partials and shortcodes.
|
||||
A template file is any file living below the `layouts` directories of either the project or any of its theme components including partials and shortcodes.
|
||||
|
||||
The function is particularly handy with dynamic path. The following example ensures the build will not break on a `.Type` missing its dedicated `header` partial.
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ aliases: []
|
|||
|
||||
## Example: Using `time` to get Month Index
|
||||
|
||||
The following example takes a UNIX timestamp---set as `utimestamp: "1489276800"` in a content's front matter---converts the timestamp (string) to an integer using the [`int` function][int], and then uses [`printf`][] to convert the `Month` property of `time` into an index.
|
||||
The following example takes a UNIX timestamp---set as `utimestamp: "1489276800"` in a content's front matter---converts the timestamp (string) to an integer using the [`int` function][int], and then uses [`printf`][] to convert the `Month` property of `time` into an index.
|
||||
|
||||
The following example may be useful when setting up [multilingual sites][multilingual]:
|
||||
|
||||
|
|
|
@ -33,6 +33,4 @@ Since both values are integers, they can be subtracted and then divided by the n
|
|||
Hugo's output is *static*. For the example above to be realistic, the site needs to be built every day.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
|
||||
[partial template]: /templates/partials/
|
||||
|
|
|
@ -21,7 +21,7 @@ aliases: []
|
|||
|
||||
|
||||
```
|
||||
{{ $url := urls.Parse "http://www.gohugo.io" }}
|
||||
{{ $url := urls.Parse "http://www.gohugo.io" }}
|
||||
```
|
||||
|
||||
and returns a [URL](https://godoc.org/net/url#URL) structure. The struct fields are accessed via the `.` notation:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue