mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
Merge commit 'dec8cd4ada29218971743333f8ac662a9c06aad8'
This commit is contained in:
@@ -135,7 +135,7 @@ tags = []
|
||||
|
||||
Hugo uses the page title and description for the title and description metadata.
|
||||
The first 6 URLs from the `images` array are used for image metadata.
|
||||
If [page bundles](/content-management/page-bundles/) are used and the `images` array is empty or undefined, images with file names matching `*feature*` or `*cover*,*thumbnail*` are used for image metadata.
|
||||
If [page bundles](/content-management/page-bundles/) are used and the `images` array is empty or undefined, images with file names matching `*feature*`, `*cover*`, or `*thumbnail*` are used for image metadata.
|
||||
|
||||
Various optional metadata can also be set:
|
||||
|
||||
@@ -203,7 +203,7 @@ description = "Text about this post"
|
||||
images = ["post-cover.png"]
|
||||
{{</ code-toggle >}}
|
||||
|
||||
If `images` aren't specified in the page front-matter, then hugo searches for [image page resources](/content-management/image-processing/) with `feature`, `cover`, or `thumbnail` in their name.
|
||||
If [page bundles](/content-management/page-bundles/) are used and the `images` array is empty or undefined, images with file names matching `*feature*`, `*cover*`, or `*thumbnail*` are used for image metadata.
|
||||
If no image resources with those names are found, the images defined in the [site config](/getting-started/configuration/) are used instead.
|
||||
If no images are found at all, then an image-less Twitter `summary` card is used instead of `summary_large_image`.
|
||||
|
||||
|
@@ -509,6 +509,20 @@ See documentation for [`with`], [`else`], and [`end`].
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
To test multiple conditions:
|
||||
|
||||
```go-html-template
|
||||
{{ $v1 := 0 }}
|
||||
{{ $v2 := 42 }}
|
||||
{{ with $v1 }}
|
||||
{{ . }}
|
||||
{{ else with $v2 }}
|
||||
{{ . }} → 42
|
||||
{{ else }}
|
||||
{{ print "v1 and v2 are falsy" }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
### Access site parameters
|
||||
|
||||
See documentation for the [`Params`](/methods/site/params/) method on a `Site` object.
|
||||
|
@@ -129,5 +129,5 @@ Hugo provides two methods to localize your menu entries. See [multilingual].
|
||||
[localize the menu entries]: /content-management/multilingual/#menus
|
||||
[menu entry defined in front matter]: /content-management/menus/#example-front-matter
|
||||
[menu entry defined in site configuration]: /content-management/menus/#example-site-configuration
|
||||
[menu and methods]: /methods/menu/
|
||||
[menu methods]: /methods/menu/
|
||||
[multilingual]: /content-management/multilingual/#menus
|
||||
|
@@ -37,12 +37,29 @@ You can organize your shortcodes in subdirectories, e.g. in `layouts/shortcodes/
|
||||
|
||||
Note the forward slash.
|
||||
|
||||
### Shortcode template lookup order
|
||||
### Template lookup order
|
||||
|
||||
Shortcode templates have a simple [lookup order]:
|
||||
Hugo selects shortcode templates based on the shortcode name, the current output format, and the current language. The examples below are sorted by specificity in descending order. The least specific path is at the bottom of the list.
|
||||
|
||||
1. `/layouts/shortcodes/<SHORTCODE>.html`
|
||||
2. `/themes/<THEME>/layouts/shortcodes/<SHORTCODE>.html`
|
||||
Shortcode name|Output format|Language|Template path
|
||||
:--|:--|:--|:--
|
||||
foo|html|en|layouts/shortcodes/foo.en.html
|
||||
foo|html|en|layouts/shortcodes/foo.html.html
|
||||
foo|html|en|layouts/shortcodes/foo.html
|
||||
foo|html|en|layouts/shortcodes/foo.html.en.html
|
||||
|
||||
Shortcode name|Output format|Language|Template path
|
||||
:--|:--|:--|:--
|
||||
foo|rss|en|layouts/shortcodes/foo.en.xml
|
||||
foo|rss|en|layouts/shortcodes/foo.rss.xml
|
||||
foo|rss|en|layouts/shortcodes/foo.en.html
|
||||
foo|rss|en|layouts/shortcodes/foo.rss.en.xml
|
||||
foo|rss|en|layouts/shortcodes/foo.xml
|
||||
foo|rss|en|layouts/shortcodes/foo.html.en.html
|
||||
foo|rss|en|layouts/shortcodes/foo.html.html
|
||||
foo|rss|en|layouts/shortcodes/foo.html
|
||||
|
||||
Note that templates provided by a theme or module always take precedence.
|
||||
|
||||
### Positional vs. named arguments
|
||||
|
||||
|
Reference in New Issue
Block a user