Squashed 'docs/' changes from 316cec249..4eb10c1a9
4eb10c1a9 Set a sensible maxAge on the image cache 2c37f4f89 Update lists.md 8690c018f Update introduction.md 0458c3d88 Update index.md 150982f5e Update index.md 50dc0b6b9 Update multilingual.md 648598090 Configure image cache to use :cacheDir/images 4dfb523c3 Update introduction.md b94d42e6f Add text to social images d3253d2aa Add resources/_gen/images/ to .gitignore 8a56e1dfd Delete resources/_gen/images 1521e79b6 Update introduction.md c7110a597 Update introduction.md f7c4d220f Update introduction.md c14ecf1ff Update introduction.md c4b388c20 Fix shortcode in hugo-pipes/introduction (#1605) d9876bd68 Update introduction.md a39a532d5 Update introduction.md fa8758122 netlify: Hugo 0.90.1 50cc40570 Update Contribute to Hugo Development fc98fc82c Add .vscode dir to .gitignore (#1602) 8f8bcdefc Add frontmatter param to code-toggle shortcode (#1601) f3b432c7c Add markdownlint configuration file (#1597) 7ea3aea92 netlify: Bump to 0.90.0 e2b6f990b docs: Regenerate docs helper c02259e33 Merge commit '8d9511a08f14260cbfb73119e4afae50e5a9966d' 2e3573899 Add custom font support to images.Text 3186e6458 images: Text filter that draws text with the given options (#9239) 424f219eb tpl/transform: Optional options for highlight func 7993f17d0 Implement XML data support 1eb9d34cf Make resources.Get use a file cache for remote resources 8a0fffd56 Add remote support to resources.Get git-subtree-dir: docs git-subtree-split: 4eb10c1a9689aebf652011a6260a14bf8a3dcef4
2
.gitignore
vendored
|
@ -1,7 +1,9 @@
|
||||||
/.idea
|
/.idea
|
||||||
|
/.vscode
|
||||||
/public
|
/public
|
||||||
node_modules
|
node_modules
|
||||||
nohup.out
|
nohup.out
|
||||||
.DS_Store
|
.DS_Store
|
||||||
trace.out
|
trace.out
|
||||||
.hugo_build.lock
|
.hugo_build.lock
|
||||||
|
resources/_gen/images/
|
4
.markdownlint.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
|
||||||
|
|
||||||
|
MD013: false # Line length
|
||||||
|
MD033: false # Inline HTML
|
BIN
_vendor/github.com/gohugoio/gohugoioTheme/assets/opengraph/gohugoio-card-base-1.png
generated
Normal file
After Width: | Height: | Size: 237 KiB |
BIN
_vendor/github.com/gohugoio/gohugoioTheme/assets/opengraph/mulish-black.ttf
generated
Normal file
|
@ -47,9 +47,9 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ partial "site-manifest.html" . }}
|
{{ partial "site-manifest.html" . }}
|
||||||
{{- partial "head-additions.html" . -}}
|
{{- partial "head-additions.html" . -}}
|
||||||
{{- template "_internal/opengraph.html" . -}}
|
{{- partial "opengraph/opengraph.html" . -}}
|
||||||
{{- template "_internal/schema.html" . -}}
|
{{- template "_internal/schema.html" . -}}
|
||||||
{{- template "_internal/twitter_cards.html" . -}}
|
{{- partial "opengraph/twitter_cards.html" . -}}
|
||||||
|
|
||||||
{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }}
|
{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }}
|
||||||
{{ partial "gtag" . }}
|
{{ partial "gtag" . }}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
<h6 class="f4 dark-gray mb2">
|
<h6 class="f6 dark-gray mb2">
|
||||||
<a href="{{ .Permalink }}" class="hide-child link primary-color">
|
Last updated: {{ .Lastmod.Format "January 2, 2006" }}{{ with .GitInfo }}: <a class="hide-child link primary-color" href="{{$.Site.Params.ghrepo}}commit/{{ .Hash }}">{{ .Subject }} ({{ .AbbreviatedHash }})</a>{{end }}
|
||||||
<span class="nl3 child">{{ partial "svg/link-permalink.svg" (dict "size" "14px") }}</span>
|
|
||||||
“{{ .Title }}”
|
|
||||||
</a> was last updated: {{ .Lastmod.Format "January 2, 2006" }}{{ with .GitInfo }}: <a class="hide-child link primary-color" href="{{$.Site.Params.ghrepo}}commit/{{ .Hash }}">{{ .Subject }} ({{ .AbbreviatedHash }})</a>{{end }}
|
|
||||||
</h6>
|
</h6>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{ $currentPage := . }}
|
{{ $currentPage := . }}
|
||||||
{{ $menu := .Site.Menus.docs.ByWeight }}
|
{{ $menu := .Site.Menus.docs.ByWeight }}
|
||||||
<ul class="list dib ph0 ma0 scrolling-touch tc">
|
<ul class="list dib ph0 scrolling-touch tc">
|
||||||
{{ range $menu }}{{ $post := printf "%s" .Post }}
|
{{ range $menu }}{{ $post := printf "%s" .Post }}
|
||||||
<li class="tl dib ma0 hover-bg-black w-100{{ if eq $post "break" }} mb2 bb b--mid-gray{{ end }}">
|
<li class="tl dib ma0 hover-bg-black w-100{{ if eq $post "break" }} mb2 bb b--mid-gray{{ end }}">
|
||||||
<a href="{{.URL}}" class="ttu f6 link primary-color-light hover-white db brand-font mb1 ma0 w-100 pv2 ph4{{if $currentPage.IsMenuCurrent "main" . }} bg-primary-color{{end}}">
|
<a href="{{.URL}}" class="ttu f6 link primary-color-light hover-white db brand-font mb1 ma0 w-100 pv2 ph4{{if $currentPage.IsMenuCurrent "main" . }} bg-primary-color{{end}}">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{ $currentPage := . }}
|
{{ $currentPage := . }}
|
||||||
{{ $menu := .Site.Menus.global }}
|
{{ $menu := .Site.Menus.global }}
|
||||||
<ul class="list hidden dib ph0 ma0 scrolling-touch tc">
|
<ul class="list hidden dib ph0 scrolling-touch tc">
|
||||||
{{ range $menu }}
|
{{ range $menu }}
|
||||||
<li class="tl dib ma0 hover-bg-black w-100">
|
<li class="tl dib ma0 hover-bg-black w-100">
|
||||||
<a href="{{.URL}}" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4{{if $currentPage.IsMenuCurrent "main" . }} bg-primary-color{{end}}">
|
<a href="{{.URL}}" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4{{if $currentPage.IsMenuCurrent "main" . }} bg-primary-color{{end}}">
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<div class="globalmenu mobilemenu pb3 dn">
|
<div class="globalmenu mobilemenu pb1 dn">
|
||||||
{{ partial "nav-links-global-mobile.html" . }}
|
{{ partial "nav-links-global-mobile.html" . }}
|
||||||
</div>
|
</div>
|
||||||
<div class="docsmenu mobilemenu pb3 dn">
|
<div class="docsmenu mobilemenu pb1 dn">
|
||||||
{{ partial "nav-links-docs-mobile.html" . }}
|
{{ partial "nav-links-docs-mobile.html" . }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex dn-l justify-between">
|
<div class="flex dn-l justify-between">
|
||||||
<button class="js-toggle flex-auto dib dn-l f6 tc db mt4-ns ph3 pv2 link mr2 white bg-primary-color-dark hover-bg-primary-color ba b--white-40 w-auto" data-target=".globalmenu">Menu</button>
|
<button class="js-toggle flex-auto dib dn-l f6 tc db ph3 pv2 link mr2 white bg-primary-color-dark hover-bg-primary-color ba b--white-40 w-auto" data-target=".globalmenu">Menu</button>
|
||||||
|
|
||||||
<button class="js-toggle flex-auto dib dn-l f6 tc db mt4-ns ph3 pv2 link white bg-primary-color-dark hover-bg-primary-color ba b--white-40 w-auto" data-target=".docsmenu">Docs Menu</button>
|
<button class="js-toggle flex-auto dib dn-l f6 tc db ph3 pv2 link white bg-primary-color-dark hover-bg-primary-color ba b--white-40 w-auto" data-target=".docsmenu">Docs Menu</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
24
_vendor/github.com/gohugoio/gohugoioTheme/layouts/partials/opengraph/get-featured-image.html
generated
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{{ $images := $.Resources.ByType "image" }}
|
||||||
|
{{ $featured := $images.GetMatch "*feature*" }}
|
||||||
|
{{ if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end }}
|
||||||
|
{{ if not $featured }}
|
||||||
|
{{ $featured = resources.Get "/opengraph/gohugoio-card-base-1.png" }}
|
||||||
|
{{ $size := 80 }}
|
||||||
|
{{ $title := $.LinkTitle }}
|
||||||
|
{{ if gt (len $title) 20 }}
|
||||||
|
{{ $size = 70 }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $text := $title }}
|
||||||
|
{{ $textOptions := dict
|
||||||
|
"color" "#FFF"
|
||||||
|
"size" $size
|
||||||
|
"lineSpacing" 10
|
||||||
|
"x" 65 "y" 80
|
||||||
|
"font" (resources.Get "/opengraph/mulish-black.ttf")
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{ $featured = $featured | images.Filter (images.Text $text $textOptions) }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ return $featured }}
|
42
_vendor/github.com/gohugoio/gohugoioTheme/layouts/partials/opengraph/opengraph.html
generated
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<meta property="og:title" content="{{ .Title }}" />
|
||||||
|
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
|
||||||
|
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
||||||
|
<meta property="og:url" content="{{ .Permalink }}" />
|
||||||
|
|
||||||
|
{{- with $.Params.images -}}
|
||||||
|
{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $featured := partial "opengraph/get-featured-image.html" . }}
|
||||||
|
{{- with $featured -}}
|
||||||
|
<meta property="og:image" content="{{ $featured.Permalink }}"/>
|
||||||
|
{{- else -}}
|
||||||
|
{{- with $.Site.Params.images }}<meta property="og:image" content="{{ index . 0 | absURL }}"/>{{ end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if .IsPage }}
|
||||||
|
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
||||||
|
<meta property="article:section" content="{{ .Section }}" />
|
||||||
|
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||||
|
{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
|
||||||
|
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
|
||||||
|
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
|
||||||
|
{{- with .Params.videos }}{{- range . }}
|
||||||
|
<meta property="og:video" content="{{ . | absURL }}" />
|
||||||
|
{{ end }}{{ end }}
|
||||||
|
|
||||||
|
{{- /* If it is part of a series, link to related articles */}}
|
||||||
|
{{- $permalink := .Permalink }}
|
||||||
|
{{- $siteSeries := .Site.Taxonomies.series }}
|
||||||
|
{{ with .Params.series }}{{- range $name := . }}
|
||||||
|
{{- $series := index $siteSeries ($name | urlize) }}
|
||||||
|
{{- range $page := first 6 $series.Pages }}
|
||||||
|
{{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{ end }}{{ end }}
|
||||||
|
|
||||||
|
{{- /* Facebook Page Admin ID for Domain Insights */}}
|
||||||
|
{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
|
22
_vendor/github.com/gohugoio/gohugoioTheme/layouts/partials/opengraph/twitter_cards.html
generated
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{{- with $.Params.images -}}
|
||||||
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
|
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
|
||||||
|
{{ else -}}
|
||||||
|
{{- $featured := partial "opengraph/get-featured-image.html" . }}
|
||||||
|
{{- with $featured -}}
|
||||||
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
|
<meta name="twitter:image" content="{{ $featured.Permalink }}"/>
|
||||||
|
{{- else -}}
|
||||||
|
{{- with $.Site.Params.images -}}
|
||||||
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
|
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
|
||||||
|
{{ else -}}
|
||||||
|
<meta name="twitter:card" content="summary"/>
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
<meta name="twitter:title" content="{{ .Title }}"/>
|
||||||
|
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
|
||||||
|
{{ with .Site.Social.twitter -}}
|
||||||
|
<meta name="twitter:site" content="@{{ . }}"/>
|
||||||
|
{{ end -}}
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
<img src="/images/gopher-side_color.svg" alt="" class="absolute-l bottom-0 dn db-l h4 right-0 z-999"/>
|
<img src="/images/gopher-side_color.svg" alt="" class="absolute-l bottom-0 dn db-l h4 right-0 z-999"/>
|
||||||
|
|
||||||
<div class="bg-primary-color-dark bottom-0 left-0 right-0 dn-l fixed pb3 ph3 w-100">
|
<div class="bg-primary-color-dark bottom-0 left-0 right-0 dn-l fixed pb3 ph3 pt3 w-100">
|
||||||
{{- partial "nav-mobile.html" . -}}
|
{{- partial "nav-mobile.html" . -}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
<label class="clip" for="search-input">Search</label>
|
<label class="clip" for="search-input">Search</label>
|
||||||
<input type="search" id="search-input" class="needs-js bg-left bn f5 input-reset lh-solid mt3 mt0-ns pl4 pv2 w5 white" placeholder="Search the Docs" name="search-input" value="" style="background: url('/images/icon-search.png') 5px 11px/16px 16px no-repeat; background-color: rgba(255,255,255,0);">
|
<input type="search" id="search-input" class="needs-js bg-left bn f5 input-reset lh-solid mt3 mt0-ns pl4 pv2 w5 white" placeholder="Search the Docs" name="search-input" value="" style="background: url('/images/icon-search.png') 5px 11px/16px 16px no-repeat; background-color: rgba(255,255,255,0);">
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"highlight.js": "^9.13.1",
|
"highlight.js": "^9.13.1",
|
||||||
"lazysizes": "^5.2.1",
|
"lazysizes": "^5.2.1",
|
||||||
"mini-css-extract-plugin": "^0.4.4",
|
"mini-css-extract-plugin": "^0.4.4",
|
||||||
"postcss": "^7.0.32",
|
"postcss": "^7.0.36",
|
||||||
"postcss-cssnext": "^3.1.0",
|
"postcss-cssnext": "^3.1.0",
|
||||||
"postcss-import": "^12.0.1",
|
"postcss-import": "^12.0.1",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
# github.com/gohugoio/gohugoioTheme v0.0.0-20210409071416-c88da48134b7
|
# github.com/gohugoio/gohugoioTheme v0.0.0-20211211134334-0fe25799bb58
|
||||||
|
|
|
@ -42,8 +42,8 @@ maxAge = -1
|
||||||
dir = ":cacheDir/:project"
|
dir = ":cacheDir/:project"
|
||||||
maxAge = -1
|
maxAge = -1
|
||||||
[caches.images]
|
[caches.images]
|
||||||
dir = ":resourceDir/_gen"
|
dir = ":cacheDir/images"
|
||||||
maxAge = -1
|
maxAge = "1440h"
|
||||||
[caches.assets]
|
[caches.assets]
|
||||||
dir = ":resourceDir/_gen"
|
dir = ":resourceDir/_gen"
|
||||||
maxAge = -1
|
maxAge = -1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Multilingual Mode
|
title: Multilingual Mode
|
||||||
linktitle: Multilingual and i18n
|
linktitle: Multilingual
|
||||||
description: Hugo supports the creation of websites with multiple languages side by side.
|
description: Hugo supports the creation of websites with multiple languages side by side.
|
||||||
date: 2017-01-10
|
date: 2017-01-10
|
||||||
publishdate: 2017-01-10
|
publishdate: 2017-01-10
|
||||||
|
|
|
@ -402,13 +402,7 @@ Last but not least you should accept the contributor license agreement (CLA). A
|
||||||
|
|
||||||
### Automatic builds
|
### Automatic builds
|
||||||
|
|
||||||
We use the [Travis CI loop](https://travis-ci.org/gohugoio/hugo) (Linux and OS X) and [AppVeyor](https://ci.appveyor.com/project/gohugoio/hugo/branch/master) (Windows) to compile Hugo with your additions. This should ensure that everything works as expected before merging your pull request. This in most cases only relevant if you made changes to the codebase of Hugo.
|
We use a GitHub Actions workflow to build and test. This is a matrix build across combinations of operating system (masOS, Windows, and Ubuntu) and Go versions. The workflow is triggered by the submission of a pull request. If you are a first-time contributor, the workflow requires approval from a project maintainer.
|
||||||
|
|
||||||
![Automatic builds and their status](/images/contribute/development/ci-errors.png)
|
|
||||||
|
|
||||||
Above you can see that Travis wasn't able to compile the changes in this pull request. Click on "Details" and try to investigate why the build failed. But it doesn't have to be your fault. Mostly, the `master` branch that we used as foundation for your pull request should build without problems.
|
|
||||||
|
|
||||||
If you have questions, leave a comment in the pull request. We are willing to assist you.
|
|
||||||
|
|
||||||
## Where to start?
|
## Where to start?
|
||||||
|
|
||||||
|
|
BIN
content/en/featured.png
Normal file
After Width: | Height: | Size: 72 KiB |
|
@ -1,23 +1,104 @@
|
||||||
---
|
---
|
||||||
title: highlight
|
title: highlight
|
||||||
linktitle: highlight
|
linktitle: highlight
|
||||||
description: Takes a string of code and language declaration and uses Chroma to return syntax-highlighted HTML.
|
description: Renders code with a syntax highlighter.
|
||||||
date: 2017-02-01
|
date: 2017-02-01
|
||||||
publishdate: 2017-02-01
|
publishdate: 2017-02-01
|
||||||
lastmod: 2017-02-01
|
lastmod: 2021-12-06
|
||||||
categories: [functions]
|
categories: [functions]
|
||||||
menu:
|
menu:
|
||||||
docs:
|
docs:
|
||||||
parent: "functions"
|
parent: "functions"
|
||||||
keywords: [highlighting,code blocks,syntax]
|
keywords: [highlighting,code blocks,syntax]
|
||||||
signature: ["highlight INPUT LANG OPTIONS"]
|
signature: ["transform.Highlight INPUT LANG [OPTIONS]","highlight INPUT LANG [OPTIONS]"]
|
||||||
workson: []
|
|
||||||
hugoversion:
|
|
||||||
relatedfuncs: []
|
relatedfuncs: []
|
||||||
deprecated: false
|
deprecated: false
|
||||||
|
toc: true
|
||||||
---
|
---
|
||||||
|
The `highlight` function uses the [Chroma] syntax highlighter, supporting over 200 languages with more than 40 available styles.
|
||||||
|
|
||||||
[`highlight` is used in Hugo's built-in `highlight` shortcode][highlight].
|
## Parameters
|
||||||
|
|
||||||
|
INPUT
|
||||||
|
: The code to highlight.
|
||||||
|
|
||||||
[highlight]: /content-management/shortcodes/#highlight
|
LANG
|
||||||
|
: The language of the code to highlight. Choose from one of the [supported languages]. Case-insensitive.
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
: An optional, comma-separated list of zero or more [options]. Set default values in [site configuration].
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
lineNos
|
||||||
|
: Boolean. Default is `false`.\
|
||||||
|
Display a number at the beginning of each line.
|
||||||
|
|
||||||
|
lineNumbersInTable
|
||||||
|
: Boolean. Default is `true`.\
|
||||||
|
Render the highlighted code in an HTML table with two cells. The left table cell contains the line numbers. The right table cell contains the code, allowing a user to select and copy the code without line numbers. Irrelevant if `lineNos` is false.
|
||||||
|
|
||||||
|
anchorLineNos
|
||||||
|
: Boolean. Default is `false`.\
|
||||||
|
Render each line number as an HTML anchor element, and set the `id` attribute of the surrounding `<span>` to the line number. Irrelevant if `lineNos` is false.
|
||||||
|
|
||||||
|
lineAnchors
|
||||||
|
: String. Default is `""`.\
|
||||||
|
When rendering a line number as an HTML anchor element, prepend this value to the `id` attribute of the surrounding `<span>`. This provides unique `id` attributes when a page contains two or more code blocks. Irrelevant if `lineNos` or `anchorLineNos` is false.
|
||||||
|
|
||||||
|
lineNoStart
|
||||||
|
: Integer. Default is `1`.\
|
||||||
|
The number to display at the beginning of the first line. Irrelevant if `lineNos` is false.
|
||||||
|
|
||||||
|
hl_Lines
|
||||||
|
: String. Default is `""`.\
|
||||||
|
A space-separated list of lines to emphasize within the highlighted code. To emphasize lines 2, 3, 4, and 7, set this value to `2-4 7`. This option is independent of the `lineNoStart` option.
|
||||||
|
|
||||||
|
style
|
||||||
|
: String. Default is `monokai`.\
|
||||||
|
The CSS styles to apply to the highlighted code. See the [style gallery] for examples. Case-sensitive.
|
||||||
|
|
||||||
|
noClasses
|
||||||
|
: Boolean. Default is `true`.\
|
||||||
|
Use inline CSS styles instead of an external CSS file. To use an external CSS file, set this value to `false` and [generate the file with the hugo client][hugo client].
|
||||||
|
|
||||||
|
tabWidth
|
||||||
|
: Integer. Default is `4`.\
|
||||||
|
Substitute this number of spaces for each tab character in your highlighted code.
|
||||||
|
|
||||||
|
guessSyntax
|
||||||
|
: Boolean. Default is `false`.\
|
||||||
|
If the `LANG` parameter is blank or an unrecognized language, auto-detect the language if possible, otherwise use a fallback language.
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
|
||||||
|
|
||||||
|
`lineNos=inline`
|
||||||
|
: equivalent to `lineNos=true` and `lineNumbersInTable=false`
|
||||||
|
|
||||||
|
`lineNos=table`
|
||||||
|
: equivalent to `lineNos=true` and `lineNumbersInTable=true`
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ $input := `fmt.Println("Hello World!")` }}
|
||||||
|
{{ transform.Highlight $input "go" }}
|
||||||
|
|
||||||
|
{{ $input := `console.log('Hello World!');` }}
|
||||||
|
{{ $lang := "js" }}
|
||||||
|
{{ transform.Highlight $input $lang "lineNos=table, style=api" }}
|
||||||
|
|
||||||
|
{{ $input := `echo "Hello World!"` }}
|
||||||
|
{{ $lang := "bash" }}
|
||||||
|
{{ $options := slice "lineNos=table" "style=dracula" }}
|
||||||
|
{{ transform.Highlight $input $lang (delimit $options ",") }}
|
||||||
|
```
|
||||||
|
|
||||||
|
[Chroma]: https://github.com/alecthomas/chroma
|
||||||
|
[hugo client]: {{< relref "commands/hugo_gen_chromastyles" >}}
|
||||||
|
[options]: {{< relref "#options" >}}
|
||||||
|
[site configuration]: {{< relref "getting-started/configuration-markup#highlight">}}
|
||||||
|
[style gallery]: https://xyproto.github.io/splash/docs/
|
||||||
|
[supported languages]: {{< relref "content-management/syntax-highlighting#list-of-chroma-highlighting-languages" >}}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
title: Image Functions
|
title: Image Filters
|
||||||
description: The images namespace provides a list of filters and other image related functions.
|
description: The images namespace provides a list of filters and other image related functions.
|
||||||
date: 2017-02-01
|
date: 2017-02-01
|
||||||
categories: [functions]
|
categories: [functions]
|
||||||
|
@ -11,12 +11,9 @@ keywords: [images]
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
## Image Filters
|
|
||||||
|
|
||||||
See [images.Filter](#filter) for how to apply these filters to an image.
|
See [images.Filter](#filter) for how to apply these filters to an image.
|
||||||
|
|
||||||
### Overlay
|
## Overlay
|
||||||
|
|
||||||
{{< new-in "0.80.0" >}}
|
{{< new-in "0.80.0" >}}
|
||||||
|
|
||||||
|
@ -40,7 +37,42 @@ A shorter version of the above, if you only need to apply the filter once:
|
||||||
|
|
||||||
The above will overlay `$logo` in the upper left corner of `$img` (at position `x=50, y=50`).
|
The above will overlay `$logo` in the upper left corner of `$img` (at position `x=50, y=50`).
|
||||||
|
|
||||||
### Brightness
|
## Text
|
||||||
|
|
||||||
|
{{< new-in "0.90.0" >}}
|
||||||
|
|
||||||
|
Using the `Text` filter, you can add text to an image.
|
||||||
|
|
||||||
|
{{% funcsig %}}
|
||||||
|
images.Text TEXT DICT)
|
||||||
|
{{% /funcsig %}}
|
||||||
|
|
||||||
|
The following example will add the text `Hugo rocks!` to the image with the specified color, size and position.
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ $img := resources.Get "/images/background.png"}}
|
||||||
|
{{ $img = $img.Filter (images.Text "Hugo rocks!" (dict
|
||||||
|
"color" "#ffffff"
|
||||||
|
"size" 60
|
||||||
|
"linespacing" 2
|
||||||
|
"x" 10
|
||||||
|
"y" 20
|
||||||
|
))}}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can load a custom font if needed. Load the font as a Hugo `Resource` and set it as an option:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
|
||||||
|
{{ $font := resources.Get "https://github.com/google/fonts/raw/main/apache/roboto/static/Roboto-Black.ttf" }}
|
||||||
|
{{ $img := resources.Get "/images/background.png"}}
|
||||||
|
{{ $img = $img.Filter (images.Text "Hugo rocks!" (dict
|
||||||
|
"font" $font
|
||||||
|
))}}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Brightness
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Brightness PERCENTAGE
|
images.Brightness PERCENTAGE
|
||||||
|
@ -58,7 +90,7 @@ images.ColorBalance PERCENTAGERED PERCENTAGEGREEN PERCENTAGEBLUE
|
||||||
ColorBalance creates a filter that changes the color balance of an image.
|
ColorBalance creates a filter that changes the color balance of an image.
|
||||||
The percentage parameters for each color channel (red, green, blue) must be in range (-100, 500).
|
The percentage parameters for each color channel (red, green, blue) must be in range (-100, 500).
|
||||||
|
|
||||||
### Colorize
|
## Colorize
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Colorize HUE SATURATION PERCENTAGE
|
images.Colorize HUE SATURATION PERCENTAGE
|
||||||
|
@ -69,7 +101,7 @@ The hue parameter is the angle on the color wheel, typically in range (0, 360).
|
||||||
The saturation parameter must be in range (0, 100).
|
The saturation parameter must be in range (0, 100).
|
||||||
The percentage parameter specifies the strength of the effect, it must be in range (0, 100).
|
The percentage parameter specifies the strength of the effect, it must be in range (0, 100).
|
||||||
|
|
||||||
### Contrast
|
## Contrast
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Contrast PERCENTAGE
|
images.Contrast PERCENTAGE
|
||||||
|
@ -78,7 +110,7 @@ images.Contrast PERCENTAGE
|
||||||
Contrast creates a filter that changes the contrast of an image.
|
Contrast creates a filter that changes the contrast of an image.
|
||||||
The percentage parameter must be in range (-100, 100).
|
The percentage parameter must be in range (-100, 100).
|
||||||
|
|
||||||
### Gamma
|
## Gamma
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Gamma GAMMA
|
images.Gamma GAMMA
|
||||||
|
@ -88,7 +120,7 @@ Gamma creates a filter that performs a gamma correction on an image.
|
||||||
The gamma parameter must be positive. Gamma = 1 gives the original image.
|
The gamma parameter must be positive. Gamma = 1 gives the original image.
|
||||||
Gamma less than 1 darkens the image and gamma greater than 1 lightens it.
|
Gamma less than 1 darkens the image and gamma greater than 1 lightens it.
|
||||||
|
|
||||||
### GaussianBlur
|
## GaussianBlur
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.GaussianBlur SIGMA
|
images.GaussianBlur SIGMA
|
||||||
|
@ -104,7 +136,7 @@ images.Grayscale
|
||||||
|
|
||||||
Grayscale creates a filter that produces a grayscale version of an image.
|
Grayscale creates a filter that produces a grayscale version of an image.
|
||||||
|
|
||||||
### Hue
|
## Hue
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Hue SHIFT
|
images.Hue SHIFT
|
||||||
|
@ -113,7 +145,7 @@ images.Hue SHIFT
|
||||||
Hue creates a filter that rotates the hue of an image.
|
Hue creates a filter that rotates the hue of an image.
|
||||||
The hue angle shift is typically in range -180 to 180.
|
The hue angle shift is typically in range -180 to 180.
|
||||||
|
|
||||||
### Invert
|
## Invert
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Invert
|
images.Invert
|
||||||
|
@ -121,7 +153,7 @@ images.Invert
|
||||||
|
|
||||||
Invert creates a filter that negates the colors of an image.
|
Invert creates a filter that negates the colors of an image.
|
||||||
|
|
||||||
### Pixelate
|
## Pixelate
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Pixelate SIZE
|
images.Pixelate SIZE
|
||||||
|
@ -129,7 +161,7 @@ images.Pixelate SIZE
|
||||||
|
|
||||||
Pixelate creates a filter that applies a pixelation effect to an image.
|
Pixelate creates a filter that applies a pixelation effect to an image.
|
||||||
|
|
||||||
### Saturation
|
## Saturation
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Saturation PERCENTAGE
|
images.Saturation PERCENTAGE
|
||||||
|
@ -137,7 +169,7 @@ images.Saturation PERCENTAGE
|
||||||
|
|
||||||
Saturation creates a filter that changes the saturation of an image.
|
Saturation creates a filter that changes the saturation of an image.
|
||||||
|
|
||||||
### Sepia
|
## Sepia
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Sepia PERCENTAGE
|
images.Sepia PERCENTAGE
|
||||||
|
@ -145,7 +177,7 @@ images.Sepia PERCENTAGE
|
||||||
|
|
||||||
Sepia creates a filter that produces a sepia-toned version of an image.
|
Sepia creates a filter that produces a sepia-toned version of an image.
|
||||||
|
|
||||||
### Sigmoid
|
## Sigmoid
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.Sigmoid MIDPOINT FACTOR
|
images.Sigmoid MIDPOINT FACTOR
|
||||||
|
@ -154,7 +186,7 @@ images.Sigmoid MIDPOINT FACTOR
|
||||||
Sigmoid creates a filter that changes the contrast of an image using a sigmoidal function and returns the adjusted image.
|
Sigmoid creates a filter that changes the contrast of an image using a sigmoidal function and returns the adjusted image.
|
||||||
It's a non-linear contrast change useful for photo adjustments as it preserves highlight and shadow detail.
|
It's a non-linear contrast change useful for photo adjustments as it preserves highlight and shadow detail.
|
||||||
|
|
||||||
### UnsharpMask
|
## UnsharpMask
|
||||||
|
|
||||||
{{% funcsig %}}
|
{{% funcsig %}}
|
||||||
images.UnsharpMask SIGMA AMOUNT THRESHOLD
|
images.UnsharpMask SIGMA AMOUNT THRESHOLD
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "transform.Unmarshal"
|
title: "transform.Unmarshal"
|
||||||
description: "`transform.Unmarshal` (alias `unmarshal`) parses the input and converts it into a map or an array. Supported formats are JSON, TOML, YAML and CSV."
|
description: "`transform.Unmarshal` (alias `unmarshal`) parses the input and converts it into a map or an array. Supported formats are JSON, TOML, YAML, XML and CSV."
|
||||||
date: 2018-12-23
|
date: 2018-12-23
|
||||||
categories: [functions]
|
categories: [functions]
|
||||||
menu:
|
menu:
|
||||||
|
@ -45,3 +45,32 @@ Example:
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ $csv := "a;b;c" | transform.Unmarshal (dict "delimiter" ";") }}
|
{{ $csv := "a;b;c" | transform.Unmarshal (dict "delimiter" ";") }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## XML data
|
||||||
|
|
||||||
|
As a convenience, Hugo allows you to access XML data in the same way that you access JSON, TOML, and YAML: you do not need to specify the root node when accessing the data.
|
||||||
|
|
||||||
|
To get the contents of `<title>` in the document below, you use `{{ .message.title }}`:
|
||||||
|
|
||||||
|
```
|
||||||
|
<root>
|
||||||
|
<message>
|
||||||
|
<title>Hugo rocks!</title>
|
||||||
|
<description>Thanks for using Hugo</description>
|
||||||
|
</message>
|
||||||
|
</root>
|
||||||
|
```
|
||||||
|
|
||||||
|
The following example lists the items of an RSS feed:
|
||||||
|
|
||||||
|
```
|
||||||
|
{{ with resources.Get "https://example.com/rss.xml" | transform.Unmarshal }}
|
||||||
|
{{ range .channel.item }}
|
||||||
|
<strong>{{ .title | plainify | htmlUnescape }}</strong><br />
|
||||||
|
<p>{{ .description | plainify | htmlUnescape }}</p>
|
||||||
|
{{ $link := .link | plainify | htmlUnescape }}
|
||||||
|
<a href="{{ $link }}">{{ $link }}</a><br />
|
||||||
|
<hr>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
```
|
||||||
|
|
|
@ -686,6 +686,9 @@ maxAge = -1
|
||||||
[caches.getcsv]
|
[caches.getcsv]
|
||||||
dir = ":cacheDir/:project"
|
dir = ":cacheDir/:project"
|
||||||
maxAge = -1
|
maxAge = -1
|
||||||
|
[caches.getresource]
|
||||||
|
dir = ":cacheDir/:project"
|
||||||
|
maxAge = -1
|
||||||
[caches.images]
|
[caches.images]
|
||||||
dir = ":resourceDir/_gen"
|
dir = ":resourceDir/_gen"
|
||||||
maxAge = -1
|
maxAge = -1
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Hugo Pipes Introduction
|
title: Hugo Pipes Introduction
|
||||||
|
linkTitle: Hugo Pipes
|
||||||
description: Hugo Pipes is Hugo's asset processing set of functions.
|
description: Hugo Pipes is Hugo's asset processing set of functions.
|
||||||
date: 2018-07-14
|
date: 2018-07-14
|
||||||
publishdate: 2018-07-14
|
publishdate: 2018-07-14
|
||||||
|
@ -13,45 +14,100 @@ menu:
|
||||||
weight: 01
|
weight: 01
|
||||||
sections_weight: 01
|
sections_weight: 01
|
||||||
draft: false
|
draft: false
|
||||||
|
toc: true
|
||||||
aliases: [/assets/]
|
aliases: [/assets/]
|
||||||
---
|
---
|
||||||
|
|
||||||
### Asset directory
|
## Get Resource with resources.Get
|
||||||
|
|
||||||
|
In order to process an asset with Hugo Pipes, it must be retrieved as a `Resource` using `resources.Get`. The first argument can be either a local the path to file relative to the `asset` directory/directories or a remote URL.
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ $local := resources.Get "sass/main.scss" }}
|
||||||
|
{{ $remote := resources.Get "https://www.example.com/styles.scss" }}
|
||||||
|
```
|
||||||
|
|
||||||
|
`resources.Get` will always return `nil` if the resource could not be found.
|
||||||
|
|
||||||
|
### Error Handling
|
||||||
|
|
||||||
|
{{< new-in "0.90.1" >}}
|
||||||
|
|
||||||
|
The return value from `resources.Get` includes an `.Err` method that will return an error if the call failed. If you want to just log any error as a `WARNING` you can use a construct similar to the one below.
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ with resources.Get "https://gohugo.io/images/gohugoio-card-1.png" }}
|
||||||
|
{{ with .Err }}
|
||||||
|
{{ warnf "%s" . }}
|
||||||
|
{{ else }}
|
||||||
|
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that if you do not handle `.Err` yourself, Hugo will fail the build the first time you start using the `Resource` object.
|
||||||
|
|
||||||
|
### Remote Options
|
||||||
|
|
||||||
|
When fetching a remote `Resource`, `resources.Get` takes an optional options map as the last argument, e.g.:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ $resource := resources.Get "https://example.org/api" (dict "headers" (dict "Authorization" "Bearer abcd")) }}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you need multiple values for the same header key, use a slice:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ $resource := resources.Get "https://example.org/api" (dict "headers" (dict "X-List" (slice "a" "b" "c"))) }}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also change the request method and set the request body:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ $postResponse := resources.Get "https://example.org/api" (dict
|
||||||
|
"method" "post"
|
||||||
|
"body" `{"complete": true}`
|
||||||
|
"headers" (dict
|
||||||
|
"Content-Type" "application/json"
|
||||||
|
)
|
||||||
|
)}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Caching of Remote Resources
|
||||||
|
|
||||||
|
Remote resources fetched with `resources.Get` will be cached on disk. See [Configure File Caches](/getting-started/configuration/#configure-file-caches) for details.
|
||||||
|
|
||||||
|
## Asset directory
|
||||||
|
|
||||||
Asset files must be stored in the asset directory. This is `/assets` by default, but can be configured via the configuration file's `assetDir` key.
|
Asset files must be stored in the asset directory. This is `/assets` by default, but can be configured via the configuration file's `assetDir` key.
|
||||||
|
|
||||||
### From file to resource
|
|
||||||
|
|
||||||
In order to process an asset with Hugo Pipes, it must be retrieved as a resource using `resources.Get`, which takes one argument: the filepath of the file relative to the asset directory.
|
### Asset Publishing
|
||||||
|
|
||||||
```go-html-template
|
Assets will only be published (to `/public`) if `.Permalink` or `.RelPermalink` is used. You can use `.Content` to inline the asset.
|
||||||
{{ $style := resources.Get "sass/main.scss" }}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Asset publishing
|
## Go Pipes
|
||||||
|
|
||||||
Assets will only be published (to `/public`) if `.Permalink` or `.RelPermalink` is used.
|
|
||||||
|
|
||||||
### Go Pipes
|
|
||||||
|
|
||||||
For improved readability, the Hugo Pipes examples of this documentation will be written using [Go Pipes](/templates/introduction/#pipes):
|
For improved readability, the Hugo Pipes examples of this documentation will be written using [Go Pipes](/templates/introduction/#pipes):
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ $style := resources.Get "sass/main.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }}
|
{{ $style := resources.Get "sass/main.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }}
|
||||||
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
||||||
```
|
```
|
||||||
|
|
||||||
### Method aliases
|
## Method aliases
|
||||||
|
|
||||||
Each Hugo Pipes `resources` transformation method uses a __camelCased__ alias (`toCSS` for `resources.ToCSS`).
|
Each Hugo Pipes `resources` transformation method uses a __camelCased__ alias (`toCSS` for `resources.ToCSS`).
|
||||||
Non-transformation methods deprived of such aliases are `resources.Get`, `resources.FromString`, `resources.ExecuteAsTemplate` and `resources.Concat`.
|
Non-transformation methods deprived of such aliases are `resources.Get`, `resources.FromString`, `resources.ExecuteAsTemplate` and `resources.Concat`.
|
||||||
|
|
||||||
The example above can therefore also be written as follows:
|
The example above can therefore also be written as follows:
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ $style := resources.Get "sass/main.scss" | toCSS | minify | fingerprint }}
|
{{ $style := resources.Get "sass/main.scss" | toCSS | minify | fingerprint }}
|
||||||
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
||||||
```
|
```
|
||||||
|
|
||||||
### Caching
|
## Caching
|
||||||
|
|
||||||
Hugo Pipes invocations are cached based on the entire _pipe chain_.
|
Hugo Pipes invocations are cached based on the entire _pipe chain_.
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ date: 2017-02-01
|
||||||
publishdate: 2017-02-01
|
publishdate: 2017-02-01
|
||||||
lastmod: 2017-03-12
|
lastmod: 2017-03-12
|
||||||
categories: [templates]
|
categories: [templates]
|
||||||
keywords: [data,dynamic,csv,json,toml,yaml]
|
keywords: [data,dynamic,csv,json,toml,yaml,xml]
|
||||||
menu:
|
menu:
|
||||||
docs:
|
docs:
|
||||||
parent: "templates"
|
parent: "templates"
|
||||||
|
@ -20,7 +20,7 @@ toc: true
|
||||||
|
|
||||||
<!-- begin data files -->
|
<!-- begin data files -->
|
||||||
|
|
||||||
Hugo supports loading data from YAML, JSON, and TOML files located in the `data` directory in the root of your Hugo project.
|
Hugo supports loading data from YAML, JSON, XML, and TOML files located in the `data` directory in the root of your Hugo project.
|
||||||
|
|
||||||
{{< youtube FyPgSuwIMWQ >}}
|
{{< youtube FyPgSuwIMWQ >}}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ Hugo supports loading data from YAML, JSON, and TOML files located in the `data`
|
||||||
|
|
||||||
The `data` folder is where you can store additional data for Hugo to use when generating your site. Data files aren't used to generate standalone pages; rather, they're meant to be supplemental to content files. This feature can extend the content in case your front matter fields grow out of control. Or perhaps you want to show a larger dataset in a template (see example below). In both cases, it's a good idea to outsource the data in their own files.
|
The `data` folder is where you can store additional data for Hugo to use when generating your site. Data files aren't used to generate standalone pages; rather, they're meant to be supplemental to content files. This feature can extend the content in case your front matter fields grow out of control. Or perhaps you want to show a larger dataset in a template (see example below). In both cases, it's a good idea to outsource the data in their own files.
|
||||||
|
|
||||||
These files must be YAML, JSON, or TOML files (using the `.yml`, `.yaml`, `.json`, or `.toml` extension). The data will be accessible as a `map` in the `.Site.Data` variable.
|
These files must be YAML, JSON, XML, or TOML files (using the `.yml`, `.yaml`, `.json`, `.xml`, or `.toml` extension). The data will be accessible as a `map` in the `.Site.Data` variable.
|
||||||
|
|
||||||
## Data Files in Themes
|
## Data Files in Themes
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ Discover a new favorite bass player? Just add another `.toml` file in the same d
|
||||||
|
|
||||||
## Example: Accessing Named Values in a Data File
|
## Example: Accessing Named Values in a Data File
|
||||||
|
|
||||||
Assume you have the following data structure in your `User0123.[yml|toml|json]` data file located directly in `data/`:
|
Assume you have the following data structure in your `User0123.[yml|toml|xml|json]` data file located directly in `data/`:
|
||||||
|
|
||||||
{{< code-toggle file="User0123" >}}
|
{{< code-toggle file="User0123" >}}
|
||||||
Name: User0123
|
Name: User0123
|
||||||
|
@ -232,6 +232,7 @@ If you change any local file and the LiveReload is triggered, Hugo will read the
|
||||||
* [YAML Spec][yaml]
|
* [YAML Spec][yaml]
|
||||||
* [JSON Spec][json]
|
* [JSON Spec][json]
|
||||||
* [CSV Spec][csv]
|
* [CSV Spec][csv]
|
||||||
|
* [XML Spec][xml]
|
||||||
|
|
||||||
[config]: /getting-started/configuration/
|
[config]: /getting-started/configuration/
|
||||||
[csv]: https://tools.ietf.org/html/rfc4180
|
[csv]: https://tools.ietf.org/html/rfc4180
|
||||||
|
@ -247,3 +248,4 @@ If you change any local file and the LiveReload is triggered, Hugo will read the
|
||||||
[variadic]: https://en.wikipedia.org/wiki/Variadic_function
|
[variadic]: https://en.wikipedia.org/wiki/Variadic_function
|
||||||
[vars]: /variables/
|
[vars]: /variables/
|
||||||
[yaml]: https://yaml.org/spec/
|
[yaml]: https://yaml.org/spec/
|
||||||
|
[xml]: https://www.w3.org/XML/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Introduction to Hugo Templating
|
title: Introduction to Hugo Templating
|
||||||
linktitle: Introduction
|
linktitle: Templating
|
||||||
description: Hugo uses Go's `html/template` and `text/template` libraries as the basis for the templating.
|
description: Hugo uses Go's `html/template` and `text/template` libraries as the basis for the templating.
|
||||||
date: 2017-02-01
|
date: 2017-02-01
|
||||||
publishdate: 2017-02-01
|
publishdate: 2017-02-01
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Lists of Content in Hugo
|
title: Lists of Content in Hugo
|
||||||
linktitle: List Page Templates
|
linktitle: List Templates
|
||||||
description: Lists have a specific meaning and usage in Hugo when it comes to rendering your site homepage, section page, taxonomy list, or taxonomy terms list.
|
description: Lists have a specific meaning and usage in Hugo when it comes to rendering your site homepage, section page, taxonomy list, or taxonomy terms list.
|
||||||
date: 2017-02-01
|
date: 2017-02-01
|
||||||
publishdate: 2017-02-01
|
publishdate: 2017-02-01
|
||||||
|
|
|
@ -1893,7 +1893,8 @@
|
||||||
"type": "application/rss+xml",
|
"type": "application/rss+xml",
|
||||||
"string": "application/rss+xml",
|
"string": "application/rss+xml",
|
||||||
"suffixes": [
|
"suffixes": [
|
||||||
"xml"
|
"xml",
|
||||||
|
"rss"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3880,6 +3881,12 @@
|
||||||
"Aliases": null,
|
"Aliases": null,
|
||||||
"Examples": null
|
"Examples": null
|
||||||
},
|
},
|
||||||
|
"Text": {
|
||||||
|
"Description": "",
|
||||||
|
"Args": null,
|
||||||
|
"Aliases": null,
|
||||||
|
"Examples": null
|
||||||
|
},
|
||||||
"UnsharpMask": {
|
"UnsharpMask": {
|
||||||
"Description": "",
|
"Description": "",
|
||||||
"Args": null,
|
"Args": null,
|
||||||
|
@ -4517,9 +4524,9 @@
|
||||||
"Examples": null
|
"Examples": null
|
||||||
},
|
},
|
||||||
"Get": {
|
"Get": {
|
||||||
"Description": "Get locates the filename given in Hugo's assets filesystem\nand creates a Resource object that can be used for further transformations.",
|
"Description": "Get locates the filename given in Hugo's assets filesystem or downloads\na file from an URL and creates a Resource object that can be used for\nfurther transformations.\n\nFor URLs an additional argument with options can be provided.",
|
||||||
"Args": [
|
"Args": [
|
||||||
"filename"
|
"args"
|
||||||
],
|
],
|
||||||
"Aliases": null,
|
"Aliases": null,
|
||||||
"Examples": []
|
"Examples": []
|
||||||
|
|
5
go.mod
|
@ -1,5 +1,6 @@
|
||||||
module github.com/gohugoio/hugoDocs
|
module github.com/gohugoio/hugoDocs
|
||||||
|
|
||||||
go 1.12
|
go 1.16
|
||||||
|
|
||||||
|
require github.com/gohugoio/gohugoioTheme v0.0.0-20211211134334-0fe25799bb58 // indirect
|
||||||
|
|
||||||
require github.com/gohugoio/gohugoioTheme v0.0.0-20210409071416-c88da48134b7 // indirect
|
|
||||||
|
|
2
go.sum
|
@ -29,3 +29,5 @@ github.com/gohugoio/gohugoioTheme v0.0.0-20210409065807-6383d8cbaf65 h1:EJzierSW
|
||||||
github.com/gohugoio/gohugoioTheme v0.0.0-20210409065807-6383d8cbaf65/go.mod h1:kpw3SS48xZvLQGEXKu8u5XHgXkPvL8DX3oGa07+z8Bs=
|
github.com/gohugoio/gohugoioTheme v0.0.0-20210409065807-6383d8cbaf65/go.mod h1:kpw3SS48xZvLQGEXKu8u5XHgXkPvL8DX3oGa07+z8Bs=
|
||||||
github.com/gohugoio/gohugoioTheme v0.0.0-20210409071416-c88da48134b7 h1:uRCgPslaBgLYy4ANXBoPbBQVM8aNiHoxIZTKUXpkuUA=
|
github.com/gohugoio/gohugoioTheme v0.0.0-20210409071416-c88da48134b7 h1:uRCgPslaBgLYy4ANXBoPbBQVM8aNiHoxIZTKUXpkuUA=
|
||||||
github.com/gohugoio/gohugoioTheme v0.0.0-20210409071416-c88da48134b7/go.mod h1:kpw3SS48xZvLQGEXKu8u5XHgXkPvL8DX3oGa07+z8Bs=
|
github.com/gohugoio/gohugoioTheme v0.0.0-20210409071416-c88da48134b7/go.mod h1:kpw3SS48xZvLQGEXKu8u5XHgXkPvL8DX3oGa07+z8Bs=
|
||||||
|
github.com/gohugoio/gohugoioTheme v0.0.0-20211211125852-b85e21c1f3d6 h1:lAgdWrn8VEg0PrNCPX4DflCg2msDKpSYV6E8RTNV3N0=
|
||||||
|
github.com/gohugoio/gohugoioTheme v0.0.0-20211211125852-b85e21c1f3d6/go.mod h1:kpw3SS48xZvLQGEXKu8u5XHgXkPvL8DX3oGa07+z8Bs=
|
||||||
|
|
|
@ -1,41 +1,108 @@
|
||||||
{{ $file := .Get "file" }}
|
{{- /*
|
||||||
{{ $code := "" }}
|
Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
|
||||||
{{ with .Get "config" }}
|
|
||||||
{{ $file = $file | default "config" }}
|
@param {string} config
|
||||||
{{ $sections := (split . ".") }}
|
Section of site.Data.docs.config to render.
|
||||||
{{ $configSection := index $.Site.Data.docs.config $sections }}
|
Example: markup.highlight
|
||||||
{{ $code = dict $sections $configSection }}
|
Default: ""
|
||||||
{{ if $.Get "skipHeader"}}
|
@param {bool} copy
|
||||||
{{ $code = $configSection }}
|
Display a copy button.
|
||||||
{{ end }}
|
Default: true
|
||||||
{{ else }}
|
@param {string} file
|
||||||
{{ $code = $.Inner }}
|
File name to display above the rendered code.
|
||||||
{{ end }}
|
Default: ""
|
||||||
{{ $langs := (slice "yaml" "toml" "json") }}
|
@param {bool} fm
|
||||||
<div class="code relative" {{ with $file }}id="{{ . | urlize}}"{{ end }}>
|
Does Inner represent front matter?
|
||||||
|
Default: false
|
||||||
|
@param {string} Inner
|
||||||
|
Content between opening and closing shortcode tags.
|
||||||
|
Default: ""
|
||||||
|
@param {bool} skipHeader
|
||||||
|
Omit top level key(s) when rendering a section of site.Data.docs.config.
|
||||||
|
Default: false
|
||||||
|
@returns {template.HTML}
|
||||||
|
*/ -}}
|
||||||
|
|
||||||
|
{{- /* Initialize. */ -}}
|
||||||
|
{{- $config := "" -}}
|
||||||
|
{{- $copy := true -}}
|
||||||
|
{{- $file := "" -}}
|
||||||
|
{{- $fm := false -}}
|
||||||
|
{{- $skipHeader := false -}}
|
||||||
|
|
||||||
|
{{- /* Get parameters, defend against string booleans. */ -}}
|
||||||
|
{{- if .Params -}}
|
||||||
|
{{- $config = .Get "config" -}}
|
||||||
|
{{- $file = .Get "file" -}}
|
||||||
|
{{- if (isset .Params "copy") -}}
|
||||||
|
{{- if in (slice true "true") (.Get "copy") -}}
|
||||||
|
{{- $copy = true -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $copy = false -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if (isset .Params "fm") -}}
|
||||||
|
{{- if in (slice true "true") (.Get "fm") -}}
|
||||||
|
{{- $fm = true -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $fm = false -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if (isset .Params "skipHeader") -}}
|
||||||
|
{{- if in (slice true "true") (.Get "skipHeader") -}}
|
||||||
|
{{- $skipHeader = true -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $skipHeader = false -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- /* Define constants. */ -}}
|
||||||
|
{{- $delimiters := dict "toml" "+++" "yaml" "---" -}}
|
||||||
|
{{- $langs := slice "yaml" "toml" "json" -}}
|
||||||
|
{{- $placeHolder := "#-hugo-placeholder-#" -}}
|
||||||
|
|
||||||
|
{{- /* Render. */ -}}
|
||||||
|
{{- $code := "" -}}
|
||||||
|
{{- with $config -}}
|
||||||
|
{{- $file = $file | default "config" -}}
|
||||||
|
{{- $sections := (split . ".") -}}
|
||||||
|
{{- $configSection := index $.Site.Data.docs.config $sections -}}
|
||||||
|
{{- $code = dict $sections $configSection -}}
|
||||||
|
{{- if $skipHeader -}}
|
||||||
|
{{- $code = $configSection -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $code = $.Inner -}}
|
||||||
|
{{- end }}
|
||||||
|
<div class="code relative" {{ with $file }}id="{{ . | urlize }}"{{ end }}>
|
||||||
<div class="code-nav flex flex-nowrap items-stretch">
|
<div class="code-nav flex flex-nowrap items-stretch">
|
||||||
{{- with $file -}}
|
{{- with $file }}
|
||||||
<div class="san-serif f6 dib lh-solid pl2 pv2 mr2">
|
<div class="san-serif f6 dib lh-solid pl2 pv2 mr2">
|
||||||
{{ . }}.
|
{{- . -}}{{- if not $fm -}}.{{- end -}}
|
||||||
</div>
|
</div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ range $langs }}
|
{{- range $langs }}
|
||||||
<button data-toggle-tab="{{ . }}" class="tab-button {{ cond (eq . "yaml") "active" ""}} ba san-serif f6 dib lh-solid ph2 pv2">
|
<button data-toggle-tab="{{ . }}" class="tab-button {{ cond (eq . "yaml") "active" "" }} ba san-serif f6 dib lh-solid ph2 pv2">
|
||||||
{{ . }}
|
{{ . }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{{ end }}
|
{{- end }}
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
{{ range $langs }}
|
{{- range $langs }}
|
||||||
<div data-pane="{{ . }}" class="code-copy-content nt3 tab-pane {{ cond (eq . "yaml") "active" ""}}">
|
<div data-pane="{{ . }}" class="code-copy-content nt3 tab-pane {{ cond (eq . "yaml") "active" "" }}">
|
||||||
{{ highlight ($code | transform.Remarshal . | replaceRE `\n+` "\n" | safeHTML) . "" }}
|
{{- $hCode := $code | transform.Remarshal . -}}
|
||||||
|
{{- if and $fm (in (slice "toml" "yaml") .) -}}
|
||||||
|
{{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- $hCode = $hCode | replaceRE `\n+` "\n" }}
|
||||||
|
{{ highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }}
|
||||||
</div>
|
</div>
|
||||||
{{ if ne ($.Get "copy") "false" }}
|
{{- if $copy }}
|
||||||
<button class="needs-js copy copy-toggle bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button>
|
<button class="needs-js copy copy-toggle bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button>
|
||||||
{{/* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}}
|
{{- /* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */ -}}
|
||||||
{{end}}
|
{{- end -}}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,7 +3,7 @@ publish = "public"
|
||||||
command = "hugo --gc --minify"
|
command = "hugo --gc --minify"
|
||||||
|
|
||||||
[context.production.environment]
|
[context.production.environment]
|
||||||
HUGO_VERSION = "0.89.4"
|
HUGO_VERSION = "0.90.1"
|
||||||
HUGO_ENV = "production"
|
HUGO_ENV = "production"
|
||||||
HUGO_ENABLEGITINFO = "true"
|
HUGO_ENABLEGITINFO = "true"
|
||||||
|
|
||||||
|
@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true"
|
||||||
command = "hugo --gc --minify --enableGitInfo"
|
command = "hugo --gc --minify --enableGitInfo"
|
||||||
|
|
||||||
[context.split1.environment]
|
[context.split1.environment]
|
||||||
HUGO_VERSION = "0.89.4"
|
HUGO_VERSION = "0.90.1"
|
||||||
HUGO_ENV = "production"
|
HUGO_ENV = "production"
|
||||||
|
|
||||||
[context.deploy-preview]
|
[context.deploy-preview]
|
||||||
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
|
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
|
||||||
|
|
||||||
[context.deploy-preview.environment]
|
[context.deploy-preview.environment]
|
||||||
HUGO_VERSION = "0.89.4"
|
HUGO_VERSION = "0.90.1"
|
||||||
|
|
||||||
[context.branch-deploy]
|
[context.branch-deploy]
|
||||||
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
||||||
|
|
||||||
[context.branch-deploy.environment]
|
[context.branch-deploy.environment]
|
||||||
HUGO_VERSION = "0.89.4"
|
HUGO_VERSION = "0.90.1"
|
||||||
|
|
||||||
[context.next.environment]
|
[context.next.environment]
|
||||||
HUGO_ENABLEGITINFO = "true"
|
HUGO_ENABLEGITINFO = "true"
|
||||||
|
|
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 5 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 94 KiB |
Before Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 168 KiB |
Before Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 142 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 55 KiB |