Squashed 'docs/' changes from 392668f4f..32cb8785e

32cb8785e Fix page weights in content management section (#1896)
11977b96f Make relURL and related functions consistent (#1895)
f12180207 Clarify github deployment (#1894)
958877789 Remove remaining references to Highlight.js (#1893)
fc487d263 Minor edit to taxonomy page
3b6a224b2 Update theme
b28553b62 Change "flavor" to "edition" when referring to builds (#1892)
660e7581c Replaced sudo in OpenBSD with doas (#1891)
e3fcdea10 fix a few minor grammatical issues on Firebase docs (#1889)
e4c8b30eb update Static Web Apps docs (#1890)
da2197c9e Update hosting-on-firebase.md (#1347)
5f2a0c271 Adding deployment guide for Azure Static Web Apps (#1456)
5aaf570cd add Azure Static Web App config to 404 template
35fc54362 add Azure Static Web App config to 404 template
d48f67ba1 Update 01-flavors.md
11debae8d Cleaned Use of ref and relref section, added refs of index.md and _in… (#1744)
b77604078 docs: Add link to menu entry variables (#1827)
0fa8a6bf0 Misc copy edits (#1887)
c27b545ac Improve explanation of safeHTMLAttr's function (#1503)
b04a4b32e Make CLI command summaries meaningful (#1886)
dbf00a81f Fix a typo in diagrams documentation (#1885)
11f884327 docs: Clarify how to remove draft/future/expired content (#1831)
6dc9e9860 Improve complement function (#1884)
56448a51a Remove erroneous sourcemap desc (#1883)
a0d0d2829 Merge branch 'divinerites-patch-1'
10f20cb5e Add a plausible-hugo theme component
9f1413eb5 Minor edits to showcase example
7d78420db fix broken link to Isso Comments
925cb291f Make directory tree consistent with other examples
300fff092 Add link to security policy from getenv.md (#1746)
7b4c517a6 Fix docs menu weights
ce35775e0 Update faq.md (#1763)
f3fb791a4 Remove dated new-in flags (#1879)
b6c634629 Remove deprecated templating langs (#1880)
1b25ca34f Update the findRE and replaceRE functions (#1881)
28757ec73 Add Alora Labs website to showcase (#1494)
e3c4bc4e7 Remove unimplemented "ugly" property
86afd84ff Update editors.md (#1878)
44c093911 Add urlquery function docs (#1633)
16a8c3548 Update links to installation page (#1876)
9e357f078 Add missing sections to BSD installation page (#1875)
1b1291634 Promote "Installation" to a section
9dd51235b Add detail to description of .Plain page variable (#1870)
d333d0287 Minor markdown linting fix and URL updates (#1873)
d57c8aa50 Remove extraneous apostrophe (#1871)
8c25cfc5c Update index.md
09fea41e0 Add lang to fenced code block
35b904798 Add small documentation about .Site.Social.twitter variable (#1854)
672042f89 Consolidate site configuration
dfd4dd873 Add help.ampio.com showcase. (#1863)
e8d0e7bdf Include link to internal templates code (#1794)
7db6f0c01 Add example to split function (#1867)
be87dba80 Clarify split function docs (#1792)
a079193f1 Fix typo on data templates page
b234c70ee Fix data templates page (#1855)
074232b45 Update front-matter.md (#1856)
711c8fa80 Added missing default value (#1862)
034762882 Fixed some grammar issues and typos (#1865)
764574a4d Fix spelling error
2698f2d44 update URLs to prevent redirects (#1864)
68f05fdc8 Fenced code blocks should have a language specified (#1861)
24393315b GitHub Workflows security hardening (#1859)
3eeee13bf Markdown formatting: Add Fenced code block languages (#1858)
e152cdf1f netlify: Hugo 0.105.0
4c7fc9f7e Merge branch 'tempv0.105.0'
d16710afc Change anchor reference to use relref function calls (#1853)
f52af8e4a tpl/encoding: Add noHTMLEscape option to jsonify
eca0046c4 Update hosting-on-keycdn docs (#1852)
ffbe17a48 Add note for rsync deploy command (#1415)
c482133f1 docs: Update quick start to clarify the need of extended version (#1828)
1e3b33804 use correct URL for Google Search console verification (#1851)
dac034f63 Markdown and formatting fixes (#1850)
43f177e3c Fix LiveReload in quick-start (#1739)
f78deaa5f Add link for ''Hugo Shortcode Syntax Highlighting' VS Code extension (#1765)
08087ecd7 Remove some hidden pages (#1848)
b6cb5ae48 Markdown linting fixes (#1846)
527ec5941 Update hugo.md (#1742)
83e8f2168 Clarify that a shortcode with .Inner must be closed (#1785)
4193f4445 Add Super Linter GitHub Action (#1845)
fd91bfe1a Formatting and grammar fixes (#1844)
ab5a49c49 Create codeql-analysis GitHub Action (#1812)
63b3e082e Add tutorial on using fusejs to search examples (#1756)
54c253ab0 Note that Google Universal Analytics are deprecated (#1770)
385fa77c6 Update articles.toml (#1840)
5e336bd26 Replace awkward wording (ESL?) (#1842)
2446ad349 Added Introduction to Hugo tutorial/video series (#1736)
7b21b2e76 Don't use self-closing generator tag
ef73712ff Image processing. available methods: add method 'Colors' (#1837)
018f83bbe [comment platform] - add new alternative (#1751)
5636c208b Grammar and spelling fixes (#1836)
3f2e26f77 Change link of repojacking vulnerable link - JekyllToHugo (#1834)
301379fc3 fix: use shorter image URL to make it easier to read (#1835)
de5fa7b30 Update search.md to include Pagefind (#1826)
e9d72bcda Breadcrumb example: add basic accessibility (#1832)
6cffff87a netlify: Hugo 0.104.3
892360f61 Update output-formats.md
09a7a46ae Remove my defunct and little used migrator (#1824)
347434cca netlify: Hugo 0.104.2
f8c721162 Update postcss.md
c2baf7155 netlify: Hugo 0.104.1
05d1192cd Update diagrams.md (#1823)
3c43a8bbe netlify: Hugo 0.104.0
57973b334 Merge branch 'tempv0.104.0'
da775a36d docs: Regen docs helper
ae48b5901 docs: Regenerate CLI docs
af4a823b1 resources/images: Add $image.Colors
8e3f9ca64 Remove outdated IE conditional comments example (#1821)
d1a84701b fix typo in template introduction (#1820)
c0c7339e0 Update internal.md
17aefc515 Remove the recommendation about where to put the GA tempalte
263297236 Adjust GA template instructions
1cc265d99 Update the GA template usage section
e11968338 config/security: Allow proxy variables in subcommands
9218ab993 netlify: Hugo 0.103.1
0b0e890d1 Update markdownify and RenderString documentation (#1818)
50f5d4776 Fix internal link (#1817)
6beb443c5 netlify: Hugo 0.103.0
14b5af248 Merge branch 'tempv0.103.0'
548e7aa62 server: Add 404 support
3a20aa0ba Update theme

git-subtree-dir: docs
git-subtree-split: 32cb8785ea74d5b82f2e2bea79d059cab497902a
This commit is contained in:
Bjørn Erik Pedersen 2022-11-17 16:14:29 +01:00
parent 90ad804505
commit 00c4484c70
221 changed files with 2490 additions and 2824 deletions

View file

@ -34,6 +34,7 @@
"brlink", "brlink",
"Brotli", "Brotli",
"Browsersync", "Browsersync",
"canonicalization",
"canonify", "canonify",
"Catmull", "Catmull",
"Catwoman", "Catwoman",
@ -61,6 +62,8 @@
"datatable", "datatable",
"DATOCMS", "DATOCMS",
"debugconfig", "debugconfig",
"defang",
"Deindent",
"DELIM", "DELIM",
"dhersam", "dhersam",
"digitalcraftsman", "digitalcraftsman",
@ -72,17 +75,21 @@
"DRING", "DRING",
"Eiqc", "Eiqc",
"Eliott", "Eliott",
"embeddable",
"Emojify", "Emojify",
"Enwrite", "Enwrite",
"eopkg", "eopkg",
"eparis", "eparis",
"errorf", "errorf",
"erroridf", "erroridf",
"esbuild",
"Evernote", "Evernote",
"Exif",
"exitwp", "exitwp",
"expirydate", "expirydate",
"Feminella", "Feminella",
"firstpost", "firstpost",
"Flickr",
"Formspree", "Formspree",
"fpath", "fpath",
"Francia", "Francia",
@ -91,10 +98,12 @@
"funcs", "funcs",
"funcsig", "funcsig",
"Garen", "Garen",
"Garuda",
"gcloud", "gcloud",
"Getenv", "Getenv",
"getjson", "getjson",
"getpage", "getpage",
"Gitee",
"Gmfc", "Gmfc",
"Goel", "Goel",
"Gohugo", "Gohugo",
@ -106,6 +115,7 @@
"govendor", "govendor",
"Gowans", "Gowans",
"Grayscale", "Grayscale",
"Gregor",
"Gruber", "Gruber",
"gtag", "gtag",
"gvfs", "gvfs",
@ -141,10 +151,12 @@
"Joomla", "Joomla",
"JRBR", "JRBR",
"jsonify", "jsonify",
"Karmada",
"katex", "katex",
"keycdn", "keycdn",
"KEYVALS", "KEYVALS",
"kubernetes", "kubernetes",
"Kubuntu",
"Lanczos", "Lanczos",
"langformatnumber", "langformatnumber",
"lastmod", "lastmod",
@ -152,6 +164,7 @@
"linktitle", "linktitle",
"Lipi", "Lipi",
"lrwxr", "lrwxr",
"Lubuntu",
"maingo", "maingo",
"markdownified", "markdownified",
"markdownify", "markdownify",
@ -188,6 +201,7 @@
"newparam", "newparam",
"Nichlas", "Nichlas",
"Nikhil", "Nikhil",
"Nikola",
"Njjy", "Njjy",
"nlist", "nlist",
"nobr", "nobr",
@ -221,6 +235,7 @@
"Poupin", "Poupin",
"prerender", "prerender",
"println", "println",
"Pritchard",
"publishdate", "publishdate",
"Pygments", "Pygments",
"qref", "qref",
@ -249,6 +264,7 @@
"safejs", "safejs",
"Samsa", "Samsa",
"schemaorg", "schemaorg",
"setx",
"Shekhar", "Shekhar",
"Shortcode", "Shortcode",
"Shortcodes", "Shortcodes",
@ -257,7 +273,9 @@
"Sindre", "Sindre",
"sitemapindex", "sitemapindex",
"sitemapxml", "sitemapxml",
"slugorfilename",
"Smartcrop", "Smartcrop",
"Sobre",
"Sprintf", "Sprintf",
"Startseite", "Startseite",
"strconv", "strconv",
@ -278,6 +296,7 @@
"Tknx", "Tknx",
"TLDR", "TLDR",
"TMPDIR", "TMPDIR",
"toclevels",
"TOCSS", "TOCSS",
"todos", "todos",
"tojson", "tojson",
@ -288,6 +307,8 @@
"toyaml", "toyaml",
"twitteruser", "twitteruser",
"Unmarshal", "Unmarshal",
"unpublishdate",
"Unsharp",
"urlize", "urlize",
"urlset", "urlset",
"utimestamp", "utimestamp",
@ -301,15 +322,19 @@
"wibble", "wibble",
"wordcount", "wordcount",
"workson", "workson",
"Wowchemy",
"wpxr", "wpxr",
"Xbaabbab", "Xbaabbab",
"Xubuntu",
"xvzf", "xvzf",
"yoyoyo", "yoyoyo",
"yunbox",
"Zgotmpl", "Zgotmpl",
"Zorin",
"zzbbaabb", "zzbbaabb",
"مدونتي" "مدونتي"
], ],
"language": "en,en-GB,en-US,de,fr", "language": "en,en-US,de,fr",
"allowCompoundWords": true, "allowCompoundWords": true,
"files": [ "files": [
"**/*.md" "**/*.md"
@ -331,5 +356,6 @@
"**/news/*", "**/news/*",
"**/showcase/*" "**/showcase/*"
], ],
"useGitignore": true "useGitignore": true,
"enabled": true
} }

2
.github/stale.yml vendored
View file

@ -17,6 +17,6 @@ markComment: >
If you still think this is important, please tell us why. If you still think this is important, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable # Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false closeComment: false

26
.github/workflows/codeql-analysis.yml vendored Normal file
View file

@ -0,0 +1,26 @@
name: "CodeQL"
on:
schedule:
- cron: "0 0 1 * *"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: "javascript"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View file

@ -1,4 +1,4 @@
name: 'Check spelling' name: "Check spelling"
on: # rebuild any PRs and main branch changes on: # rebuild any PRs and main branch changes
push: push:
branches-ignore: branches-ignore:
@ -15,6 +15,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: streetsidesoftware/cspell-action@v2 - uses: streetsidesoftware/cspell-action@v2
with: with:
check_dot_files: false
incremental_files_only: true
inline: warning inline: warning
strict: false strict: false
incremental_files_only: true

41
.github/workflows/super-linter.yml vendored Normal file
View file

@ -0,0 +1,41 @@
name: Super Linter
on:
workflow_dispatch:
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build:
permissions:
contents: read # to fetch code (actions/checkout)
statuses: write # to mark status of each linter run (github/super-linter/slim)
name: Lint Code Base
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Lint Code Base
uses: github/super-linter/slim@v4
env:
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IGNORE_GITIGNORED_FILES: true
LINTER_RULES_PATH: /
LOG_LEVEL: NOTICE
MARKDOWN_CONFIG_FILE: .markdownlint.yaml
SUPPRESS_POSSUM: true
VALIDATE_CSS: false
VALIDATE_EDITORCONFIG: false
VALIDATE_GITLEAKS: false
VALIDATE_HTML: false
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_JSCPD: false
VALIDATE_NATURAL_LANGUAGE: false
VALIDATE_SHELL_SHFMT: false
VALIDATE_XML: false

View file

@ -1,4 +1,24 @@
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md # https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
MD013: false # Line length MD002: false
MD033: false # Inline HTML MD003: false
MD004: false
MD007: false
MD012:
maximum: 2
MD013: false
MD014: false
MD022: false
MD024: false
MD031: false
MD032: false
MD033: false
MD034: false
MD036: false
MD037: false
MD038: false
MD041: false
MD046: false
MD049: false
MD050: false
MD053: false

6
.markdownlintignore Normal file
View file

@ -0,0 +1,6 @@
**/commands/**
**/functions/**
**/news/**
**/showcase/**
**/zh/**
**/license.md

3
.textlintignore Normal file
View file

@ -0,0 +1,3 @@
**/news/**
**/showcase/**
**/zh/**

View file

@ -1,6 +1,7 @@
{ {
"recommendations": [ "recommendations": [
"DavidAnson.vscode-markdownlint",
"EditorConfig.EditorConfig", "EditorConfig.EditorConfig",
"esbenp.prettier-vscode", "streetsidesoftware.code-spell-checker"
] ]
} }

View file

@ -7,11 +7,11 @@ Documentation site for [Hugo](https://github.com/gohugoio/hugo), the very fast a
## Contributing ## Contributing
We welcome contributions to Hugo of any kind including documentation, suggestions, bug reports, pull requests etc. Also check out our [contribution guide](https://gohugo.io/contribute/documentation/). We would love to hear from you. We welcome contributions to Hugo of any kind including documentation, suggestions, bug reports, pull requests etc. Also check out our [contribution guide](https://gohugo.io/contribute/documentation/). We would love to hear from you.
Note that this repository contains solely the documentation for Hugo. For contributions that aren't documentation-related please refer to the [hugo](https://github.com/gohugoio/hugo) repository. Note that this repository contains solely the documentation for Hugo. For contributions that aren't documentation-related please refer to the [hugo](https://github.com/gohugoio/hugo) repository.
*Pull requests shall **only** contain changes to the actual documentation. However, changes on the code base of Hugo **and** the documentation shall be a single, atomic pull request in the [hugo](https://github.com/gohugoio/hugo) repository.* *Pull requests shall **only** contain changes to the actual documentation. However, changes on the codebase of Hugo **and** the documentation shall be a single, atomic pull request in the [hugo](https://github.com/gohugoio/hugo) repository.*
Spelling fixes are most welcomed, and if you want to contribute longer sections to the documentation, it would be great if you had the following criteria in mind when writing: Spelling fixes are most welcomed, and if you want to contribute longer sections to the documentation, it would be great if you had the following criteria in mind when writing:

View file

@ -1,4 +1,4 @@
/* From http://cssfontstack.com */ /* From https://www.cssfontstack.com */
code, .code, pre code, .highlight pre { code, .code, pre code, .highlight pre {
font-family: 'inconsolata',Menlo,Monaco,'Courier New',monospace; font-family: 'inconsolata',Menlo,Monaco,'Courier New',monospace;
} }

View file

@ -1,11 +0,0 @@
/* modified from:*/
@import 'highlight.js/styles/atom-one-light.css';
/* hljs-template-variable covers the handlebars templating*/
.hljs-template-variable {
color: var(--primary-color);
}
.hljs-attr {
color: var(--accent-color-light);
}

View file

@ -1,12 +1,11 @@
require("typeface-muli") require('typeface-muli');
import styles from './css/main.css'; import styles from './css/main.css';
import './js/clipboardjs.js' import './js/clipboardjs.js';
import './js/codeblocks.js' import './js/codeblocks.js';
import './js/docsearch.js' import './js/docsearch.js';
import './js/hljs.js' import './js/lazysizes.js';
import './js/lazysizes.js' import './js/menutoggle.js';
import './js/menutoggle.js' import './js/scrolldir.js';
import './js/scrolldir.js' import './js/smoothscroll.js';
import './js/smoothscroll.js' import './js/tabs.js';
import './js/tabs.js' import './js/nojs.js';
import './js/nojs.js'

View file

@ -1,19 +0,0 @@
var hljs = require('highlight.js/lib/highlight.js');
hljs.registerLanguage('bash', require('highlight.js/lib/languages/bash'));
hljs.registerLanguage('css', require('highlight.js/lib/languages/css'));
hljs.registerLanguage('markdown', require('highlight.js/lib/languages/markdown'));
hljs.registerLanguage('diff', require('highlight.js/lib/languages/diff'));
// hljs.registerLanguage('go', require('highlight.js/lib/languages/go'));
hljs.registerLanguage('javascript', require('highlight.js/lib/languages/javascript'));
hljs.registerLanguage('json', require('highlight.js/lib/languages/json'));
hljs.registerLanguage('yaml', require('highlight.js/lib/languages/yaml'));
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));
hljs.registerLanguage('html', require('highlight.js/lib/languages/handlebars'));
hljs.registerLanguage("go", function(e) {
var t = { keyword: "code output note warning break default func interface select case map struct chan else goto package switch const fallthrough if range end type continue for import return var go defer bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune id autoplay Get", literal: "file download copy true false iota nil Pages with", built_in: "append cap close complex highlight copy imag len make new panic print println real recover delete Site Data tweet youtube ref relref vimeo instagram gist figure innershortcode" };
return { aliases: ["golang","hugo"], k: t, i: "</", c: [e.CLCM, e.CBCM, { cN: "string", v: [e.QSM, { b: "'", e: "[^\\\\]'" }, { b: "`", e: "`" }] }, { cN: "number", v: [{ b: e.CNR + "[dflsi]", r: 1 }, e.CNM] }, { b: /:=/ }, { cN: "function", bK: "func", e: /\s*\{/, eE: !0, c: [e.TM, { cN: "params", b: /\(/, e: /\)/, k: t, i: /["']/ }] }] }
});
hljs.initHighlightingOnLoad();

View file

@ -4083,7 +4083,7 @@ img { max-width: 100%; }
max-width: 30em; max-width: 30em;
} }
.measure-wide-l { .measure-wide-l {
max-width: 40em; max-width: 34em;
} }
.measure-narrow-l { .measure-narrow-l {
max-width: 20em; max-width: 20em;
@ -4768,11 +4768,6 @@ h6:hover .header-link {
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
pre, .pre {
overflow-x: auto;
overflow-y: hidden;
overflow: scroll;
}
code { code {
padding: 0.2em; padding: 0.2em;
margin: 0; margin: 0;
@ -4780,7 +4775,7 @@ code {
background-color: rgba(27, 31, 35, .05); background-color: rgba(27, 31, 35, .05);
border-radius: 3px; border-radius: 3px;
} }
pre code { pre code {
display: block; display: block;
padding: 1.5em 1.5em; padding: 1.5em 1.5em;
font-size: .875rem; font-size: .875rem;
@ -4992,7 +4987,7 @@ dd {
font-size: calc(0.70833rem + 0.83333vw); font-size: calc(0.70833rem + 0.83333vw);
} }
} }
/* From http://cssfontstack.com */ /* From https://www.cssfontstack.com */
code, .code, pre code, .highlight pre { code, .code, pre code, .highlight pre {
font-family: 'inconsolata',Menlo,Monaco,'Courier New',monospace; font-family: 'inconsolata',Menlo,Monaco,'Courier New',monospace;
} }

File diff suppressed because one or more lines are too long

View file

@ -1,18 +1,22 @@
[[banners]] [[banners]]
name = "Linode" name = "Linode"
link = "https://www.linode.com/" link = "https://www.linode.com/"
logo = "/images/sponsors/linode-logo_standard_light_medium.png" logo = "/images/sponsors/linode-logo_standard_light_medium.png"
copy = "" utm_campaign = "hugosponsor"
[[banners]] [[banners]]
name = "eSolia" name = "eSolia"
link = "https://esolia.com/post/why-did-esolia-choose-hugo/" link = "https://esolia.com/post/why-did-esolia-choose-hugo/"
logo = "/images/sponsors/esolia-logo.svg" logo = "/images/sponsors/esolia-logo.svg"
copy = "" utm_campaign = "hugosponsor"
[[banners]] [[banners]]
name = "BEP Consulting" name = "ButterCMS"
link = "https://bep.consulting" link = "https://buttercms.com/hugo-cms/"
logo = "/images/sponsors/bep-consulting.svg" logo = "/images/sponsors/butter-light.svg"
bgcolor = "#004887" utm_campaign = "sponsorship"
copy = "" bgcolor = "#131A3E"
#hugohome
#hugofooter
#hugogithub

View file

@ -1,38 +1,41 @@
{{$classes_box := "ba b--dark-gray bg-light-gray br3 flex flex-column flex-wrap items-center justify-center ph3 pv4 mb4 w-100 w-30-l "}} {{ $classes_box := "ba b--dark-gray bg-light-gray br3 flex flex-column flex-wrap items-center justify-center ph3 pv4 mb4 w-100 w-30-l " }}
{{$gtag := .gtag | default "unknown" }} {{ $gtag := .gtag | default "unknown" }}
{{ $classes_box := "ba b--dark-gray bg-light-gray br3 flex flex-column flex-wrap items-center justify-center ph3 pv4 mb4 w-100 w-30-l " }}
{{ $gtag := .gtag | default "unknown" }}
{{ $utmSource := cond (eq $gtag "footer") "hugofooter" "hugohome" }}
{{ with .cx.Site.Data.sponsors }} {{ with .cx.Site.Data.sponsors }}
<section class="{{ $.classes_section | default "bg-primary-color-dark b--dark-gray bb bt ph5 pv4 w-100"}}"> <section
<div class="center mw9">  class="{{ $.classes_section | default "bg-primary-color-dark b--dark-gray bb bt ph5 pv4 w-100" }}">
<div class="center mw9">
<h3 class="b f3 mv0 light-gray">Hugo Sponsors</h3> <h3 class="b f3 mv0 light-gray">Hugo Sponsors</h3>
<div class="flex-ns flex-wrap center justify-between pt3"> <div class="flex-ns flex-wrap center justify-between pt3">
{{ range .banners }} {{ range .banners }}
{{ $banner := . }} <div
{{if .logo}} class="{{ $classes_box }} o-100"
<div class="{{$classes_box}} o-100"{{ with .bgcolor }} style="background-color: {{ . }};"{{ end}}> {{ with .bgcolor }}style="background-color: {{ . }};"{{ end }}>
{{with .link -}} {{ $url := printf "%s?%s" .link (querify "utm_source" $utmSource "utm_medium" "banner" "utm_campaign" (.utm_campaign | default "hugosponsor")) | safeURL }}
{{ $url := printf "%s?%s" . (querify "utm_source" "homepage" "utm_medium" "banner" "utm_campaign" "hugosponsor") | safeURL }} {{ if eq (getenv "HUGO_ENV") "production" | or (eq $.cx.Site.Params.env "production") }}
{{ if eq (getenv "HUGO_ENV") "production" | or (eq $.cx.Site.Params.env "production") }} {{ $gtagID := printf "Sponsor %s %s" .name $gtag | title }}
{{ $gtagID := printf "Sponsor %s %s" $banner.name $gtag | title }} <a
<a href="{{ $url }}" onclick="trackOutboundLink({{ printf "'%s', '%s'" $gtagID $url | safeJS }});" class="grow"> href="{{ $url }}"
{{ else }} onclick="trackOutboundLink({{ printf "'%s', '%s'" $gtagID $url | safeJS }});"
<a href="{{ $url }}" class="grow"> class="grow">
{{ end }} <img
{{- end}} src="{{ .logo }}"
<img src="{{ .logo }}" alt="Logo for {{ .name }}" class="img h3 center" /> alt="Logo for {{ .name }}"
{{with .link}}</a>{{end}} class="img h3 center" />
{{with .copy}} </a>
<p class="center lh-copy gray mv1 tc {{$.classes_copy | default "f5 w-70-ns"}}"> {{ else }}
{{- . -}} <a href="{{ $url }}" class="grow">
</p> <img
{{end}} src="{{ .logo }}"
</div> alt="Logo for {{ .name }}"
{{else}} class="img h3 center"
<div class="{{$classes_box}} o-10"> /></a>
<p class="b black tc">Your Logo Here</p> {{ end }}
</div> </div>
{{end}} {{ end }}
{{end}}
</div> </div>
</div> </div>
</section> </section>
{{end}} {{ end }}

View file

@ -3,14 +3,7 @@
"version": "1.1.0", "version": "1.1.0",
"description": "Default Theme for Hugo Sites", "description": "Default Theme for Hugo Sites",
"main": "index.js", "main": "index.js",
"homepage": "https://gohugo.io/", "repository": "",
"bugs": {
"url": "https://github.com/gohugoio/gohugoioTheme/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gohugoio/gohugoioTheme.git"
},
"author": "budparr", "author": "budparr",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
@ -21,14 +14,13 @@
"devDependencies": { "devDependencies": {
"clean-webpack-plugin": "^1.0.0", "clean-webpack-plugin": "^1.0.0",
"clipboard": "^2.0.4", "clipboard": "^2.0.4",
"css-loader": "^4.3.0", "css-loader": "^1.0.1",
"docsearch.js": "^2.6.1", "docsearch.js": "^2.6.1",
"file-loader": "^2.0.0", "file-loader": "^2.0.0",
"glob-all": "^3.1.0", "glob-all": "^3.1.0",
"highlight.js": "^9.13.1", "lazysizes": "^4.1.4",
"lazysizes": "^5.2.1",
"mini-css-extract-plugin": "^0.4.4", "mini-css-extract-plugin": "^0.4.4",
"postcss": "^7.0.36", "postcss": "^7.0.5",
"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",
@ -36,7 +28,7 @@
"scrolldir": "^1.4.0", "scrolldir": "^1.4.0",
"tachyons": "^4.7.0", "tachyons": "^4.7.0",
"typeface-muli": "0.0.54", "typeface-muli": "0.0.54",
"webpack": "^4.44.1", "webpack": "^4.25.1",
"webpack-command": "^0.4.2" "webpack-command": "^0.4.2"
}, },
"dependencies": {} "dependencies": {}

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 402 58"><g fill="#231F20"><path d="M24.6 23c.4 0 .7-.1 1-.2l10-5.4c1-.5 1.3-1.8.8-2.8-.5-1-1.8-1.3-2.8-.8l-9.9 5.4c-1 .3-1.5 1.3-1.3 2.3.3 1 1.3 1.7 2.3 1.5h-.1zM39.8 30.9c.3 0 .7-.1 1-.3L56.7 22c.6-.3 1-1 1-1.7 0-.8-.3-1.5-.9-1.8-.7-.4-1.4-.4-2.1-.1L38.8 27c-.9.4-1.5 1.4-1.2 2.4.2 1 1.2 1.6 2.2 1.5z"/><path d="M81 19.6c-.4-1.2-1.3-2.2-2.4-2.7L61.4 7.7c-2.8-1.4-6.1-1.4-9 0l-1.4.7L39.1 2C36.3.6 33 .6 30.1 2L2.5 16.9c-1.4.6-2.3 1.9-2.5 3.4v15.2c0 .8.4 1.5 1.1 1.8l35 19c2.8 1.4 6.2 1.4 9 0L80 37.1c.7-.3 1.1-1 1.1-1.8v-15c0-.2-.1-.5-.1-.7zm-76.5.9L32 5.6c1.6-.7 3.5-.7 5.2 0L51 13l3.3-1.8c1.7-.7 3.6-.7 5.2 0l17.1 9.2.2.1-.2.1-33.4 18c-1.7.8-3.6.8-5.2 0l-33.5-18-.2-.1h.2zm38.6 32.2c-1.6.7-3.5.7-5.1 0L4.1 34.3v-9.2L36 42.3c2.8 1.4 6.2 1.4 9 0l32-17.2v9L43.1 52.7zM115.7 10.2h18.2c8.7 0 13.1 3.1 13.1 9.1 0 1.9-.5 3.7-1.6 5.2s-2.6 2.6-4.3 3.2c2.2.4 4.2 1.5 5.7 3.1s2.2 3.6 2.2 5.7c0 3.8-1.4 6.7-4.1 8.7-2.7 2-6.6 3-11.8 3h-17.5v-5.4l1.8-.2c.4 0 .8-.2 1.1-.5.2-.4.3-.9.3-1.3V16.1l-3.1-.3v-5.6zm13.1 6.4v9h2.7c3.5 0 5.3-1.6 5.3-4.8 0-2.8-1.7-4.2-5.1-4.2h-2.9zm0 15.1v9.9h3.7c3.8 0 5.8-1.8 5.8-5.2 0-3.1-1.9-4.7-5.7-4.7h-3.8zM180.7 19v22c0 .5 0 .9.3 1.3.2.3.6.4 1 .5l1.5.1v5.2h-11.7v-3.6h-.2c-1.7 3-4.5 4.4-8.5 4.4-3.1 0-5.3-.8-6.8-2.3-1.4-1.6-2.1-4-2.1-7.3V26.2c0-.4-.1-.8-.4-1.1-.2-.3-.6-.5-1-.5l-1.6-.2V19H164v18.4c-.1 1.1.1 2.2.6 3.1.6.8 1.6 1.1 2.5 1 1.1.1 2.2-.4 2.9-1.2.7-1 1.1-2.2 1-3.4V26.3c0-.5-.1-.9-.3-1.3-.3-.3-.7-.4-1.1-.4l-1.3-.2V19h12.4zM198.9 12.3V19h8.1c2.5-1.1 4.3-3.4 5.5-6.7h5.3V19h6.9l-.5 6.3h-6.4v12.3c-.1 1.1.2 2.2.7 3.2.4.5 1.3.8 2.7.8 1.2 0 2.5-.3 3.6-.8l1.4 6.3c-2.5 1.3-5.2 1.9-7.9 1.8-1.3 0-2.5-.1-3.8-.3-.9-.2-1.8-.4-2.7-.8-.7-.3-1.3-.8-1.8-1.4-.4-.5-.8-1-1.1-1.6-.3-.6-.5-1.3-.6-2-.1-.6-.2-1.3-.3-2V25.3h-9v12.3c-.1 1 .1 2.1.6 3.1.5.7 1.4 1.1 2.3 1 1.1 0 2.2-.3 3.2-.8l1.7 6.2c-2.3 1.2-4.9 1.9-7.5 1.8-3.7 0-6.4-.9-7.9-2.6-1.5-1.7-2.3-4.2-2.3-7.6V25.3h-3.9l.8-5.5c3.6-.8 6.2-3.3 7.6-7.4l5.3-.1zM242.7 18.2c2.7-.1 5.3.6 7.5 2.2 2 1.6 3 4.1 2.8 6.6 0 6.9-5.3 10.2-16 10 .1 1.3.7 2.6 1.7 3.5 1.2 1 2.7 1.4 4.2 1.4 2.6-.1 5.2-.9 7.4-2.3l2.6 6.3c-.5.4-1 .7-1.6.9-1.3.6-2.6 1-4 1.4-1.9.5-3.8.7-5.7.7-4.9 0-8.5-1.3-10.8-4-2.3-2.6-3.5-6.2-3.5-10.7-.1-4.1 1.3-8.2 4-11.4 2.7-3 6.5-4.6 11.4-4.6zm2 9.3c0-.7-.2-1.4-.7-1.9-.5-.5-1.2-.7-1.9-.6-1.4 0-2.8.6-3.6 1.8-1 1.3-1.6 2.9-1.6 4.6 5.2.2 7.7-1.2 7.7-3.9h.1zM272.5 25.5c-1.1 0-2.1.5-2.7 1.3-.7.9-1.1 2.1-1 3.3v12.5l5.1.3v5.3h-18.1V43l1.9-.2c.4.1.8-.1 1.1-.4.2-.4.3-.9.3-1.4V26.2c0-.4-.1-.8-.3-1.2-.3-.3-.6-.4-1-.4l-2-.2V19H268v4.4h.1c.7-1.4 1.7-2.7 3-3.6 1.6-1.1 3.5-1.7 5.4-1.6 1.9-.1 3.7.2 5.4.9v11.3l-7.6.4v-3.9c0-.7-.2-1.1-.5-1.2-.4-.1-.9-.2-1.3-.2zM308.7 17.5c-1.2-.3-2.3-.4-3.4-.4-6.1 0-9.2 3.9-9.2 11.8 0 3.8.8 6.8 2.3 9 1.5 2.2 3.9 3.3 7.1 3.4 1.1 0 2.1-.1 3.2-.4.6-.2 1-.8 1-1.5v-3.7l7.3.4v10.5c-3.8 1.7-7.9 2.5-12.1 2.3-6.1 0-10.8-1.6-14.1-4.9-3.3-3.3-5-8.1-5-14.5 0-3.2.5-6.4 1.6-9.4.9-2.5 2.4-4.6 4.4-6.3 1.8-1.4 3.8-2.5 6-3.3 2.2-.7 4.6-1 6.9-1 4.2-.1 8.3.7 12.2 2.4v10l-7.4.4V19c0-.9-.3-1.4-.8-1.5zM323.6 10.2h14.6l7.5 24.8h.2l7.7-24.7h14.6v5.4l-1.8.2c-.5 0-.9.2-1.2.5-.3.4-.4.9-.3 1.3l1.9 24.8 2.9.1v5.6h-15.3v-5.5l1.8-.2c.4.1.8-.1 1-.4.2-.4.3-.9.2-1.3l-.9-16.1h-.1l-7.2 23.5h-7.1l-7-23.1h-.2l-1 17.3 2.8.2v5.6h-15.3v-5.5l1.8-.2c.5 0 .9-.2 1.2-.5.2-.4.4-.9.4-1.4l2-24.6-3.2-.2v-5.6zM385.5 41.6c3.5 0 5.3-1.4 5.3-4.2 0-1.1-.5-2.2-1.4-2.8-1.4-.8-2.9-1.4-4.5-1.8-1.3-.3-2.7-.8-4-1.3-1.2-.5-2.3-1.2-3.4-1.9-1.2-.9-2.2-2-2.8-3.3-.6-1.5-1-3.2-1-4.8-.1-3.4 1.4-6.7 4-8.8 2.7-2.1 6.2-3.1 10.6-3.1 4-.2 8 .6 11.7 2.2v9.3l-7.4.5v-2.9c0-.8-.3-1.3-.8-1.4-1.1-.3-2.2-.4-3.3-.4-1.1 0-2.2.3-3.1.8-.8.6-1.3 1.6-1.2 2.6-.1 1.1.5 2.2 1.4 2.8 1.5.9 3.1 1.6 4.8 2 1.4.4 2.5.8 3.3 1.1.9.4 1.9.8 2.8 1.3 1 .5 1.9 1.2 2.6 2 .7.9 1.2 1.8 1.6 2.9.5 1.3.7 2.6.7 4 .2 3.6-1.3 7-4.1 9.3-2.7 2.2-6.4 3.3-11.2 3.3-4.3.1-8.6-.7-12.6-2.3v-9.8l7.5-.5v3.2c0 .9.3 1.4.9 1.6 1.1.2 2.3.4 3.6.4z"/></g></svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 402 58"><g fill="#fff"><path d="M24.6 23c.4 0 .7-.1 1-.2l10-5.4c1-.5 1.3-1.8.8-2.8-.5-1-1.8-1.3-2.8-.8l-9.9 5.4c-1 .3-1.5 1.3-1.3 2.3.3 1 1.3 1.7 2.3 1.5h-.1zM39.8 30.9c.3 0 .7-.1 1-.3L56.7 22c.6-.3 1-1 1-1.7 0-.8-.3-1.5-.9-1.8-.7-.4-1.4-.4-2.1-.1L38.8 27c-.9.4-1.5 1.4-1.2 2.4.2 1 1.2 1.6 2.2 1.5z"/><path d="M81 19.6c-.4-1.2-1.3-2.2-2.4-2.7L61.4 7.7c-2.8-1.4-6.1-1.4-9 0l-1.4.7L39.1 2C36.3.6 33 .6 30.1 2L2.5 16.9c-1.4.6-2.3 1.9-2.5 3.4v15.2c0 .8.4 1.5 1.1 1.8l35 19c2.8 1.4 6.2 1.4 9 0L80 37.1c.7-.3 1.1-1 1.1-1.8v-15c0-.2-.1-.5-.1-.7zm-76.5.9L32 5.6c1.6-.7 3.5-.7 5.2 0L51 13l3.3-1.8c1.7-.7 3.6-.7 5.2 0l17.1 9.2.2.1-.2.1-33.4 18c-1.7.8-3.6.8-5.2 0l-33.5-18-.2-.1h.2zm38.6 32.2c-1.6.7-3.5.7-5.1 0L4.1 34.3v-9.2L36 42.3c2.8 1.4 6.2 1.4 9 0l32-17.2v9L43.1 52.7zM115.7 10.2h18.2c8.7 0 13.1 3.1 13.1 9.1 0 1.9-.5 3.7-1.6 5.2s-2.6 2.6-4.3 3.2c2.2.4 4.2 1.5 5.7 3.1s2.2 3.6 2.2 5.7c0 3.8-1.4 6.7-4.1 8.7-2.7 2-6.6 3-11.8 3h-17.5v-5.4l1.8-.2c.4 0 .8-.2 1.1-.5.2-.4.3-.9.3-1.3V16.1l-3.1-.3v-5.6zm13.1 6.4v9h2.7c3.5 0 5.3-1.6 5.3-4.8 0-2.8-1.7-4.2-5.1-4.2h-2.9zm0 15.1v9.9h3.7c3.8 0 5.8-1.8 5.8-5.2 0-3.1-1.9-4.7-5.7-4.7h-3.8zM180.7 19v22c0 .5 0 .9.3 1.3.2.3.6.4 1 .5l1.5.1v5.2h-11.7v-3.6h-.2c-1.7 3-4.5 4.4-8.5 4.4-3.1 0-5.3-.8-6.8-2.3-1.4-1.6-2.1-4-2.1-7.3V26.2c0-.4-.1-.8-.4-1.1-.2-.3-.6-.5-1-.5l-1.6-.2V19H164v18.4c-.1 1.1.1 2.2.6 3.1.6.8 1.6 1.1 2.5 1 1.1.1 2.2-.4 2.9-1.2.7-1 1.1-2.2 1-3.4V26.3c0-.5-.1-.9-.3-1.3-.3-.3-.7-.4-1.1-.4l-1.3-.2V19h12.4zM198.9 12.3V19h8.1c2.5-1.1 4.3-3.4 5.5-6.7h5.3V19h6.9l-.5 6.3h-6.4v12.3c-.1 1.1.2 2.2.7 3.2.4.5 1.3.8 2.7.8 1.2 0 2.5-.3 3.6-.8l1.4 6.3c-2.5 1.3-5.2 1.9-7.9 1.8-1.3 0-2.5-.1-3.8-.3-.9-.2-1.8-.4-2.7-.8-.7-.3-1.3-.8-1.8-1.4-.4-.5-.8-1-1.1-1.6-.3-.6-.5-1.3-.6-2-.1-.6-.2-1.3-.3-2V25.3h-9v12.3c-.1 1 .1 2.1.6 3.1.5.7 1.4 1.1 2.3 1 1.1 0 2.2-.3 3.2-.8l1.7 6.2c-2.3 1.2-4.9 1.9-7.5 1.8-3.7 0-6.4-.9-7.9-2.6-1.5-1.7-2.3-4.2-2.3-7.6V25.3h-3.9l.8-5.5c3.6-.8 6.2-3.3 7.6-7.4l5.3-.1zM242.7 18.2c2.7-.1 5.3.6 7.5 2.2 2 1.6 3 4.1 2.8 6.6 0 6.9-5.3 10.2-16 10 .1 1.3.7 2.6 1.7 3.5 1.2 1 2.7 1.4 4.2 1.4 2.6-.1 5.2-.9 7.4-2.3l2.6 6.3c-.5.4-1 .7-1.6.9-1.3.6-2.6 1-4 1.4-1.9.5-3.8.7-5.7.7-4.9 0-8.5-1.3-10.8-4-2.3-2.6-3.5-6.2-3.5-10.7-.1-4.1 1.3-8.2 4-11.4 2.7-3 6.5-4.6 11.4-4.6zm2 9.3c0-.7-.2-1.4-.7-1.9-.5-.5-1.2-.7-1.9-.6-1.4 0-2.8.6-3.6 1.8-1 1.3-1.6 2.9-1.6 4.6 5.2.2 7.7-1.2 7.7-3.9h.1zM272.5 25.5c-1.1 0-2.1.5-2.7 1.3-.7.9-1.1 2.1-1 3.3v12.5l5.1.3v5.3h-18.1V43l1.9-.2c.4.1.8-.1 1.1-.4.2-.4.3-.9.3-1.4V26.2c0-.4-.1-.8-.3-1.2-.3-.3-.6-.4-1-.4l-2-.2V19H268v4.4h.1c.7-1.4 1.7-2.7 3-3.6 1.6-1.1 3.5-1.7 5.4-1.6 1.9-.1 3.7.2 5.4.9v11.3l-7.6.4v-3.9c0-.7-.2-1.1-.5-1.2-.4-.1-.9-.2-1.3-.2zM308.7 17.5c-1.2-.3-2.3-.4-3.4-.4-6.1 0-9.2 3.9-9.2 11.8 0 3.8.8 6.8 2.3 9 1.5 2.2 3.9 3.3 7.1 3.4 1.1 0 2.1-.1 3.2-.4.6-.2 1-.8 1-1.5v-3.7l7.3.4v10.5c-3.8 1.7-7.9 2.5-12.1 2.3-6.1 0-10.8-1.6-14.1-4.9-3.3-3.3-5-8.1-5-14.5 0-3.2.5-6.4 1.6-9.4.9-2.5 2.4-4.6 4.4-6.3 1.8-1.4 3.8-2.5 6-3.3 2.2-.7 4.6-1 6.9-1 4.2-.1 8.3.7 12.2 2.4v10l-7.4.4V19c0-.9-.3-1.4-.8-1.5zM323.6 10.2h14.6l7.5 24.8h.2l7.7-24.7h14.6v5.4l-1.8.2c-.5 0-.9.2-1.2.5-.3.4-.4.9-.3 1.3l1.9 24.8 2.9.1v5.6h-15.3v-5.5l1.8-.2c.4.1.8-.1 1-.4.2-.4.3-.9.2-1.3l-.9-16.1h-.1l-7.2 23.5h-7.1l-7-23.1h-.2l-1 17.3 2.8.2v5.6h-15.3v-5.5l1.8-.2c.5 0 .9-.2 1.2-.5.2-.4.4-.9.4-1.4l2-24.6-3.2-.2v-5.6zM385.5 41.6c3.5 0 5.3-1.4 5.3-4.2 0-1.1-.5-2.2-1.4-2.8-1.4-.8-2.9-1.4-4.5-1.8-1.3-.3-2.7-.8-4-1.3-1.2-.5-2.3-1.2-3.4-1.9-1.2-.9-2.2-2-2.8-3.3-.6-1.5-1-3.2-1-4.8-.1-3.4 1.4-6.7 4-8.8 2.7-2.1 6.2-3.1 10.6-3.1 4-.2 8 .6 11.7 2.2v9.3l-7.4.5v-2.9c0-.8-.3-1.3-.8-1.4-1.1-.3-2.2-.4-3.3-.4-1.1 0-2.2.3-3.1.8-.8.6-1.3 1.6-1.2 2.6-.1 1.1.5 2.2 1.4 2.8 1.5.9 3.1 1.6 4.8 2 1.4.4 2.5.8 3.3 1.1.9.4 1.9.8 2.8 1.3 1 .5 1.9 1.2 2.6 2 .7.9 1.2 1.8 1.6 2.9.5 1.3.7 2.6.7 4 .2 3.6-1.3 7-4.1 9.3-2.7 2.2-6.4 3.3-11.2 3.3-4.3.1-8.6-.7-12.6-2.3v-9.8l7.5-.5v3.2c0 .9.3 1.4.9 1.6 1.1.2 2.3.4 3.6.4z"/></g></svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.7 KiB

View file

@ -1 +1 @@
# github.com/gohugoio/gohugoioTheme v0.0.0-20220912070954-88dcaf003b4d # github.com/gohugoio/gohugoioTheme v0.0.0-20221116211530-5ae8dcdd68d6

View file

@ -1,80 +0,0 @@
baseURL = "https://gohugo.io/"
paginate = 100
defaultContentLanguage = "en"
enableEmoji = true
timeZone = "Europe/Oslo"
# Set the unicode character used for the "return" link in page footnotes.
footnotereturnlinkcontents = "↩"
languageCode = "en-us"
title = "Hugo"
ignoreErrors = ["error-remote-getjson", "error-missing-instagram-accesstoken"]
googleAnalytics = "UA-7131036-4"
pluralizeListTitles = false
# We do redirects via Netlify's _redirects file, generated by Hugo (see "outputs" below).
disableAliases = true
[minify]
[minify.tdewolff]
[minify.tdewolff.css]
[minify.tdewolff.html]
keepWhitespace = true
[module]
[module.hugoVersion]
min = "0.56.0"
[[module.imports]]
path = "github.com/gohugoio/gohugoioTheme"
[outputs]
home = [ "HTML", "RSS", "REDIR", "HEADERS" ]
section = [ "HTML", "RSS"]
[mediaTypes]
[mediaTypes."text/netlify"]
delimiter = ""
[outputFormats]
[outputFormats.REDIR]
mediatype = "text/netlify"
baseName = "_redirects"
isPlainText = true
notAlternative = true
[outputFormats.HEADERS]
mediatype = "text/netlify"
baseName = "_headers"
isPlainText = true
notAlternative = true
[related]
threshold = 80
includeNewer = true
toLower = false
[[related.indices]]
name = "keywords"
weight = 100
[[related.indices]]
name = "date"
weight = 10
pattern = "2006"
[social]
twitter = "GoHugoIO"
[imaging]
# See https://github.com/disintegration/imaging
# CatmullRom is a sharp bicubic filter which should fit the docs site well with its many screenshots.
# Note that you can also set this per image processing.
resampleFilter = "CatmullRom"
# Default JPEG quality setting. Default is 75.
quality = 75
anchor = "smart"

View file

@ -1,19 +1,28 @@
baseURL = "https://gohugo.io/" baseURL = "https://gohugo.io/"
paginate = 100
defaultContentLanguage = "en" defaultContentLanguage = "en"
enableEmoji = true enableEmoji = true
# Set the unicode character used for the "return" link in page footnotes.
footnotereturnlinkcontents = "↩"
languageCode = "en-us"
title = "Hugo"
googleAnalytics = "UA-7131036-4" googleAnalytics = "UA-7131036-4"
ignoreErrors = ["error-remote-getjson", "error-missing-instagram-accesstoken"]
languageCode = "en-us"
paginate = 100
pluralizeListTitles = false pluralizeListTitles = false
timeZone = "Europe/Oslo"
title = "Hugo"
# We do redirects via Netlify's _redirects file, generated by Hugo (see "outputs" below). # We do redirects via Netlify's _redirects file, generated by Hugo (see "outputs" below).
disableAliases = true disableAliases = true
[minify]
[minify.tdewolff]
[minify.tdewolff.html]
keepWhitespace = true
[module]
[module.hugoVersion]
min = "0.56.0"
[[module.imports]]
path = "github.com/gohugoio/gohugoioTheme"
[outputs] [outputs]
home = [ "HTML", "RSS", "REDIR", "HEADERS" ] home = [ "HTML", "RSS", "REDIR", "HEADERS" ]
section = [ "HTML", "RSS"] section = [ "HTML", "RSS"]
@ -48,13 +57,10 @@ maxAge = "1440h"
dir = ":resourceDir/_gen" dir = ":resourceDir/_gen"
maxAge = -1 maxAge = -1
[related] [related]
threshold = 80 threshold = 80
includeNewer = true includeNewer = true
toLower = false toLower = false
[[related.indices]] [[related.indices]]
name = "keywords" name = "keywords"
weight = 100 weight = 100
@ -66,25 +72,13 @@ pattern = "2006"
[social] [social]
twitter = "GoHugoIO" twitter = "GoHugoIO"
# MARKDOWN
## Configuration for BlackFriday markdown parser: https://github.com/russross/blackfriday
[blackfriday]
plainIDAnchors = true
# See https://github.com/gohugoio/hugo/issues/2424
hrefTargetBlank = false
angledQuotes = false
latexDashes = true
[imaging] [imaging]
# See https://github.com/disintegration/imaging # See https://github.com/disintegration/imaging
# CatmullRom is a sharp bicubic filter which should fit the docs site well with its many screenshots. # CatmullRom is a sharp bicubic filter which should fit the docs site well with its many screenshots.
# Note that you can also set this per image processing. # Note that you can also set this per image processing.
resampleFilter = "CatmullRom" resampleFilter = "CatmullRom"
# Default JPEG quality setting. Default is 75. # Default JPEG quality setting. Default is 75.
quality = 75 quality = 75
anchor = "smart" anchor = "smart"
[taxonomies] [taxonomies]

View file

@ -1,114 +1,102 @@
[[docs]] [[docs]]
name = "About Hugo" name = "About Hugo"
weight = 1 weight = 10
identifier = "about" identifier = "about"
url = "/about/" url = "/about/"
[[docs]]
name = "Installation"
weight = 20
identifier = "installation"
url = "/installation/"
[[docs]] [[docs]]
name = "Getting Started" name = "Getting Started"
weight = 5 weight = 30
identifier = "getting-started" identifier = "getting-started"
url = "/getting-started/" url = "/getting-started/"
[[docs]] [[docs]]
name = "Hugo Modules" name = "Hugo Modules"
weight = 15 weight = 40
identifier = "modules" identifier = "modules"
post = "break" post = "break"
url = "/hugo-modules/" url = "/hugo-modules/"
# Core Menus # Core menus
[[docs]] [[docs]]
name = "Content Management" name = "Content Management"
weight = 20 weight = 50
identifier = "content-management" identifier = "content-management"
post = "expanded" post = "expanded"
url = "/content-management/" url = "/content-management/"
[[docs]] [[docs]]
name = "Templates" name = "Templates"
weight = 25 weight = 60
identifier = "templates" identifier = "templates"
url = "/templates/" url = "/templates/"
[[docs]] [[docs]]
name = "Functions" name = "Functions"
weight = 30 weight = 70
identifier = "functions" identifier = "functions"
url = "/functions/" url = "/functions/"
[[docs]] [[docs]]
name = "Variables" name = "Variables"
weight = 35 weight = 80
identifier = "variables" identifier = "variables"
url = "/variables/" url = "/variables/"
[[docs]] [[docs]]
name = "Hugo Pipes" name = "Hugo Pipes"
weight = 36 weight = 90
identifier = "pipes" identifier = "pipes"
url = "/hugo-pipes/" url = "/hugo-pipes/"
[[docs]] [[docs]]
name = "CLI" name = "CLI"
weight = 40 weight = 100
post = "break" post = "break"
identifier = "commands" identifier = "commands"
url = "/commands/" url = "/commands/"
# Low level items
# LOW LEVEL ITEMS
[[docs]] [[docs]]
name = "Troubleshooting" name = "Troubleshooting"
weight = 60 weight = 110
identifier = "troubleshooting" identifier = "troubleshooting"
url = "/troubleshooting/" url = "/troubleshooting/"
[[docs]] [[docs]]
name = "Tools" name = "Tools"
weight = 70 weight = 120
identifier = "tools" identifier = "tools"
url = "/tools/" url = "/tools/"
[[docs]] [[docs]]
name = "Hosting & Deployment" name = "Hosting & Deployment"
weight = 80 weight = 130
identifier = "hosting-and-deployment" identifier = "hosting-and-deployment"
url = "/hosting-and-deployment/" url = "/hosting-and-deployment/"
[[docs]] [[docs]]
name = "Contribute" name = "Contribute"
weight = 100 weight = 140
post = "break" post = "break"
identifier = "contribute" identifier = "contribute"
url = "/contribute/" url = "/contribute/"
#[[docs]]
# name = "Tags"
# weight = 120
# identifier = "tags"
# url = "/tags/"
# [[docs]]
# name = "Categories"
# weight = 140
# identifier = "categories"
# url = "/categories/"
######## QUICKLINKS ######## QUICKLINKS
[[quicklinks]] [[quicklinks]]
name = "Fundamentals" name = "Fundamentals"
weight = 1 weight = 1
identifier = "fundamentals" identifier = "fundamentals"
url = "/tags/fundamentals/" url = "/tags/fundamentals/"
######## GLOBAL ITEMS TO BE SHARED WITH THE HUGO SITES ######## GLOBAL ITEMS TO BE SHARED WITH THE HUGO SITES
@ -118,37 +106,37 @@
identifier = "news" identifier = "news"
url = "/news/" url = "/news/"
[[global]] [[global]]
name = "Docs" name = "Docs"
weight = 5 weight = 5
identifier = "docs" identifier = "docs"
url = "/documentation/" url = "/documentation/"
[[global]] [[global]]
name = "Themes" name = "Themes"
weight = 10 weight = 10
identifier = "themes" identifier = "themes"
url = "https://themes.gohugo.io/" url = "https://themes.gohugo.io/"
[[global]] [[global]]
name = "Showcase" name = "Showcase"
weight = 20 weight = 20
identifier = "showcase" identifier = "showcase"
url = "/showcase/" url = "/showcase/"
# Anything with a weight > 100 gets an external icon # Anything with a weight > 100 gets an external icon
[[global]]
name = "Community"
weight = 150
icon = true
identifier = "community"
post = "external"
url = "https://discourse.gohugo.io/"
[[global]]
name = "Community"
weight = 150
icon = true
identifier = "community"
post = "external"
url = "https://discourse.gohugo.io/"
[[global]] [[global]]
name = "GitHub" name = "GitHub"
weight = 200 weight = 200
identifier = "github" identifier = "github"
post = "external" post = "external"
url = "https://github.com/gohugoio/hugo" url = "https://github.com/gohugoio/hugo"

View file

@ -1,6 +1,6 @@
# Config for production # Config for production
# This is turned off in development as it is relatively slow. # This is turned off in development as it is relatively slow.
# This is needed to get accurate lastMod and Git commit info # This is needed to get accurate lastMod and Git commit info
# on the docs pages. # on the docs pages.
enableGitInfo = true enableGitInfo = true

View file

@ -34,7 +34,6 @@ This has many benefits. The most noticeable is performance. HTTP servers are *ve
* ["Top 10 Static Website Generators", Netlify blog][] * ["Top 10 Static Website Generators", Netlify blog][]
* ["The Resurgence of Static", dotCMS][dotcms] * ["The Resurgence of Static", dotCMS][dotcms]
["An Introduction to Static Site Generators", David Walsh]: https://davidwalsh.name/introduction-static-site-generators ["An Introduction to Static Site Generators", David Walsh]: https://davidwalsh.name/introduction-static-site-generators
["Static Site Generators", O'Reilly]: https://github.com/gohugoio/hugoDocs/files/1242701/static-site-generators.pdf ["Static Site Generators", O'Reilly]: https://github.com/gohugoio/hugoDocs/files/1242701/static-site-generators.pdf
["Top 10 Static Website Generators", Netlify blog]: https://www.netlify.com/blog/2016/05/02/top-ten-static-website-generators/ ["Top 10 Static Website Generators", Netlify blog]: https://www.netlify.com/blog/2016/05/02/top-ten-static-website-generators/

View file

@ -54,7 +54,6 @@ toc: true
* Support for [Go][] HTML templates * Support for [Go][] HTML templates
* [Syntax highlighting][] powered by [Chroma][] * [Syntax highlighting][] powered by [Chroma][]
[aliases]: /content-management/urls/#aliases [aliases]: /content-management/urls/#aliases
[Chroma]: https://github.com/alecthomas/chroma [Chroma]: https://github.com/alecthomas/chroma
[content summaries]: /content-management/summaries/ [content summaries]: /content-management/summaries/
@ -64,11 +63,11 @@ toc: true
[Extremely fast]: https://github.com/bep/hugo-benchmark [Extremely fast]: https://github.com/bep/hugo-benchmark
[front matter]: /content-management/front-matter/ [front matter]: /content-management/front-matter/
[functions]: /functions/ [functions]: /functions/
[Go]: https://golang.org/pkg/html/template/ [Go]: https://pkg.go.dev/html/template
[Google Analytics]: https://google-analytics.com/ [Google Analytics]: https://google-analytics.com/
[homepage]: /templates/homepage/ [homepage]: /templates/homepage/
[hostanywhere]: /hosting-and-deployment/ [hostanywhere]: /hosting-and-deployment/
[install]: /getting-started/installing/ [install]: /installation/
[LiveReload]: /getting-started/usage/ [LiveReload]: /getting-started/usage/
[organization for your projects]: /getting-started/directory-structure/ [organization for your projects]: /getting-started/directory-structure/
[pagevars]: /variables/page/ [pagevars]: /variables/page/

View file

@ -16,7 +16,6 @@ aliases: [/privacy/,/gdpr/]
toc: true toc: true
--- ---
General Data Protection Regulation ([GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation)) is a regulation in EU law on data protection and privacy for all individuals within the European Union and the European Economic Area. It became enforceable on 25 May 2018. General Data Protection Regulation ([GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation)) is a regulation in EU law on data protection and privacy for all individuals within the European Union and the European Economic Area. It became enforceable on 25 May 2018.
**Hugo is a static site generator. By using Hugo you are already standing on very solid ground. Static HTML files on disk are much easier to reason about compared to server and database driven web sites.** **Hugo is a static site generator. By using Hugo you are already standing on very solid ground. Static HTML files on disk are much easier to reason about compared to server and database driven web sites.**
@ -95,6 +94,7 @@ useSessionStorage
{{% warning %}} {{% warning %}}
`useSessionStorage` is not supported when using Google Analytics v4 (gtag.js). `useSessionStorage` is not supported when using Google Analytics v4 (gtag.js).
{{% /warning %}} {{% /warning %}}
### Instagram ### Instagram
simple simple
@ -116,8 +116,7 @@ enableDNT
simple simple
: If simple mode is enabled, a static and no-JS version of a tweet will be built. : If simple mode is enabled, a static and no-JS version of a tweet will be built.
**Note:** If you use the _simple mode_ for Twitter, you may want to disable the inline styles provided by Hugo:
**Note:** If you use the _simple mode_ for Twitter, you may want to disable the inlines styles provided by Hugo:
{{< code-toggle file="config">}} {{< code-toggle file="config">}}
[services] [services]
@ -137,4 +136,3 @@ enableDNT
simple simple
: If simple mode is enabled, the video thumbnail is fetched from Vimeo's servers and it is overlayed with a play button. If the user clicks to play the video, it will open in a new tab directly on Vimeo's website. : If simple mode is enabled, the video thumbnail is fetched from Vimeo's servers and it is overlayed with a play button. If the user clicks to play the video, it will open in a new tab directly on Vimeo's website.

View file

@ -10,7 +10,6 @@ menu:
weight: 4 weight: 4
weight: 5 weight: 5
sections_weight: 5 sections_weight: 5
draft: false
aliases: [/security/] aliases: [/security/]
toc: true toc: true
--- ---
@ -28,11 +27,8 @@ But when developing and building your site, the runtime is the `hugo` executable
* User-defined components have read-only access to the filesystem. * User-defined components have read-only access to the filesystem.
* We shell out to some external binaries to support [Asciidoctor](/content-management/formats/#list-of-content-formats) and similar, but those binaries and their flags are predefined and disabled by default (see [Security Policy](#security-policy)). General functions to run arbitrary external OS commands have been [discussed](https://github.com/gohugoio/hugo/issues/796), but not implemented because of security concerns. * We shell out to some external binaries to support [Asciidoctor](/content-management/formats/#list-of-content-formats) and similar, but those binaries and their flags are predefined and disabled by default (see [Security Policy](#security-policy)). General functions to run arbitrary external OS commands have been [discussed](https://github.com/gohugoio/hugo/issues/796), but not implemented because of security concerns.
## Security Policy ## Security Policy
{{< new-in "0.91.0" >}}
Hugo has a built-in security policy that restricts access to [os/exec](https://pkg.go.dev/os/exec), remote communication and similar. Hugo has a built-in security policy that restricts access to [os/exec](https://pkg.go.dev/os/exec), remote communication and similar.
The default configuration is listed below. Any build using features not in the allow list of the security policy will fail with a detailed message about what needs to be done. Most of these settings are allow lists (string or slice, [Regular Expressions](https://pkg.go.dev/regexp) or `none` which matches nothing). The default configuration is listed below. Any build using features not in the allow list of the security policy will fail with a detailed message about what needs to be done. Most of these settings are allow lists (string or slice, [Regular Expressions](https://pkg.go.dev/regexp) or `none` which matches nothing).
@ -41,7 +37,7 @@ The default configuration is listed below. Any build using features not in the a
Note that these and other config settings in Hugo can be overridden by the OS environment. If you want to block all remote HTTP fetching of data: Note that these and other config settings in Hugo can be overridden by the OS environment. If you want to block all remote HTTP fetching of data:
``` ```txt
HUGO_SECURITY_HTTP_URLS=none hugo HUGO_SECURITY_HTTP_URLS=none hugo
``` ```
@ -57,7 +53,7 @@ These are the security threats as defined by [OWASP](https://en.wikipedia.org/wi
For HTML output, this is the core security model: For HTML output, this is the core security model:
https://golang.org/pkg/html/template/#hdr-Security_Model <https://pkg.go.dev/html/template#hdr-Security_Model>
In short: In short:

View file

@ -47,7 +47,7 @@ Hugo is for people building a blog, a company site, a portfolio site, documentat
[Firebase]: https://firebase.google.com/docs/hosting/ "Firebase static hosting" [Firebase]: https://firebase.google.com/docs/hosting/ "Firebase static hosting"
[GitHub Pages]: https://pages.github.com/ [GitHub Pages]: https://pages.github.com/
[GitLab Pages]: https://about.gitlab.com/features/pages/ [GitLab Pages]: https://about.gitlab.com/features/pages/
[Go language]: https://golang.org/ [Go language]: https://go.dev/
[GoDaddy]: https://www.godaddy.com/ "GoDaddy.com Hosting" [GoDaddy]: https://www.godaddy.com/ "GoDaddy.com Hosting"
[Google Cloud Storage]: https://cloud.google.com/storage/ [Google Cloud Storage]: https://cloud.google.com/storage/
[Heroku]: https://www.heroku.com/ [Heroku]: https://www.heroku.com/

View file

@ -26,7 +26,7 @@ To load completions for every new session, execute once:
#### macOS: #### macOS:
hugo completion bash > /usr/local/etc/bash_completion.d/hugo hugo completion bash > $(brew --prefix)/etc/bash_completion.d/hugo
You will need to start a new shell for this setup to take effect. You will need to start a new shell for this setup to take effect.

View file

@ -16,6 +16,10 @@ to enable it. You can execute the following once:
echo "autoload -U compinit; compinit" >> ~/.zshrc echo "autoload -U compinit; compinit" >> ~/.zshrc
To load completions in your current shell session:
source <(hugo completion zsh); compdef _hugo hugo
To load completions for every new session, execute once: To load completions for every new session, execute once:
#### Linux: #### Linux:
@ -24,7 +28,7 @@ To load completions for every new session, execute once:
#### macOS: #### macOS:
hugo completion zsh > /usr/local/share/zsh/site-functions/_hugo hugo completion zsh > $(brew --prefix)/share/zsh/site-functions/_hugo
You will need to start a new shell for this setup to take effect. You will need to start a new shell for this setup to take effect.

View file

@ -36,6 +36,7 @@ hugo new [path] [flags]
--disableKinds strings disable different kind of pages (home, RSS etc.) --disableKinds strings disable different kind of pages (home, RSS etc.)
--editor string edit new content with this editor, if provided --editor string edit new content with this editor, if provided
--enableGitInfo add Git revision, date, author, and CODEOWNERS info to the pages --enableGitInfo add Git revision, date, author, and CODEOWNERS info to the pages
-f, --force overwrite file if it already exists
--forceSyncStatic copy all files when static is changed. --forceSyncStatic copy all files when static is changed.
--gc enable to run some cleanup tasks (remove unused cache files) after the build --gc enable to run some cleanup tasks (remove unused cache files) after the build
-h, --help help for new -h, --help help for new

View file

@ -1,20 +1,16 @@
--- ---
title: Content Management title: Content Management
linktitle: Content Management Overview linkTitle: Content Management Overview
description: Hugo makes managing large static sites easy with support for archetypes, content types, menus, cross references, summaries, and more. description: Hugo makes managing large static sites easy with support for archetypes, content types, menus, cross references, summaries, and more.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 1 weight: 10
keywords: [source, organization] keywords: [source, organization]
categories: [content management] categories: [content management]
weight: 01 #rem
draft: false
aliases: [/content/,/content/organization]
toc: false toc: false
weight: 10
aliases: [/content/,/content/organization]
--- ---
A static site generator needs to extend beyond front matter and a couple of templates to be both scalable and *manageable*. Hugo was designed with not only developers in mind, but also content managers and authors. A static site generator needs to extend beyond front matter and a couple of templates to be both scalable and *manageable*. Hugo was designed with not only developers in mind, but also content managers and authors.

View file

@ -1,20 +1,17 @@
--- ---
title: Archetypes title: Archetypes
linktitle: Archetypes linkTitle: Archetypes
description: Archetypes are templates used when creating new content. description: Archetypes are templates used when creating new content.
date: 2017-02-01
publishdate: 2017-02-01
keywords: [archetypes,generators,metadata,front matter] keywords: [archetypes,generators,metadata,front matter]
categories: ["content management"] categories: [content management]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 70 weight: 140
quicklinks: quicklinks:
weight: 70 #rem
draft: false
aliases: [/content/archetypes/]
toc: true toc: true
weight: 140
aliases: [/content/archetypes/]
--- ---
## What are Archetypes? ## What are Archetypes?
@ -69,7 +66,6 @@ It will create a new newsletter type of content file based on the archetype temp
The above _newsletter type archetype_ illustrates the possibilities: The full Hugo `.Site` and all of Hugo&#39;s template funcs can be used in the archetype file. The above _newsletter type archetype_ illustrates the possibilities: The full Hugo `.Site` and all of Hugo&#39;s template funcs can be used in the archetype file.
## Directory based archetypes ## Directory based archetypes
Since Hugo `0.49` you can use complete directories as archetype templates. Given this archetype directory: Since Hugo `0.49` you can use complete directories as archetype templates. Given this archetype directory:
@ -90,8 +86,6 @@ hugo new --kind post-bundle posts/my-post
Will create a new folder in `/content/posts/my-post` with the same set of files as in the `post-bundle` archetypes folder. All content files (`index.md` etc.) can contain template logic, and will receive the correct `.Site` for the content's language. Will create a new folder in `/content/posts/my-post` with the same set of files as in the `post-bundle` archetypes folder. All content files (`index.md` etc.) can contain template logic, and will receive the correct `.Site` for the content's language.
[archetypes directory]: /getting-started/directory-structure/ [archetypes directory]: /getting-started/directory-structure/
[content types]: /content-management/types/ [content types]: /content-management/types/
[front matter]: /content-management/front-matter/ [front matter]: /content-management/front-matter/

View file

@ -1,19 +1,16 @@
--- ---
title: Build Options title: Build Options
linktitle: Build Options linkTitle: Build Options
description: Build options help define how Hugo must treat a given page when building the site. description: Build options help define how Hugo must treat a given page when building the site.
date: 2020-03-02
publishdate: 2020-03-02
keywords: [build,content,front matter, page resources] keywords: [build,content,front matter, page resources]
categories: ["content management"] categories: [content management]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 31 weight: 70
weight: 31 #rem
draft: false
aliases: [/content/build-options/]
toc: true toc: true
weight: 70
aliases: [/content/build-options/]
--- ---
They are stored in a reserved Front Matter object named `_build` with the following defaults: They are stored in a reserved Front Matter object named `_build` with the following defaults:
@ -26,9 +23,10 @@ _build:
{{< /code-toggle >}} {{< /code-toggle >}}
#### render #### render
If `always`, the page will be treated as a published page, holding its dedicated output files (`index.html`, etc...) and permalink. If `always`, the page will be treated as a published page, holding its dedicated output files (`index.html`, etc...) and permalink.
{{< new-in "0.76.0" >}} We extended this property from a boolean to an enum in Hugo 0.76.0. Valid values are: We extended this property from a boolean to an enum in Hugo 0.76.0. Valid values are:
never never
: The page will not be included in any page collection. : The page will not be included in any page collection.
@ -52,13 +50,13 @@ always (default)
: The page will be included in all page collections, e.g. `site.RegularPages`, `$page.Pages`. : The page will be included in all page collections, e.g. `site.RegularPages`, `$page.Pages`.
local local
: The page will be included in any _local_ page collection, e.g. `$page.RegularPages`, `$page.Pages`. One use case for this would be to create fully navigable, but headless content sections. {{< new-in "0.68.0" >}} : The page will be included in any _local_ page collection, e.g. `$page.RegularPages`, `$page.Pages`. One use case for this would be to create fully navigable, but headless content sections.
If true, the page will be treated as part of the project's collections and, when appropriate, returned by Hugo's listing methods (`.Pages`, `.RegularPages` etc...). If true, the page will be treated as part of the project's collections and, when appropriate, returned by Hugo's listing methods (`.Pages`, `.RegularPages` etc...).
#### publishResources #### publishResources
If set to true the [Bundle's Resources]({{< relref "content-management/page-bundles" >}}) will be published. If set to true the [Bundle's Resources]({{< relref "content-management/page-bundles" >}}) will be published.
Setting this to false will still publish Resources on demand (when a resource's `.Permalink` or `.RelPermalink` is invoked from the templates) but will skip the others. Setting this to false will still publish Resources on demand (when a resource's `.Permalink` or `.RelPermalink` is invoked from the templates) but will skip the others.
{{% note %}} {{% note %}}
@ -70,6 +68,7 @@ Any page, regardless of their build options, will always be available using the
### Illustrative use cases ### Illustrative use cases
#### Not publishing a page #### Not publishing a page
Project needs a "Who We Are" content file for Front Matter and body to be used by the homepage but nowhere else. Project needs a "Who We Are" content file for Front Matter and body to be used by the homepage but nowhere else.
```yaml ```yaml

View file

@ -1,19 +1,16 @@
--- ---
title: Comments title: Comments
linktitle: Comments linkTitle: Comments
description: Hugo ships with an internal Disqus template, but this isn't the only commenting system that will work with your new Hugo website. description: Hugo ships with an internal Disqus template, but this isn't the only commenting system that will work with your new Hugo website.
date: 2017-02-01
publishdate: 2017-02-01
keywords: [sections,content,organization] keywords: [sections,content,organization]
categories: [project organization, fundamentals] categories: [project organization, fundamentals]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 140 weight: 220
weight: 140 #rem
draft: false
aliases: [/extras/comments/]
toc: true toc: true
weight: 220
aliases: [/extras/comments/]
--- ---
Hugo ships with support for [Disqus](https://disqus.com/), a third-party service that provides comment and community capabilities to websites via JavaScript. Hugo ships with support for [Disqus](https://disqus.com/), a third-party service that provides comment and community capabilities to websites via JavaScript.
@ -42,7 +39,7 @@ For many websites, this is enough configuration. However, you also have the opti
Disqus has its own [internal template](https://gohugo.io/templates/internal/#disqus) available, to render it add the following code where you want comments to appear: Disqus has its own [internal template](https://gohugo.io/templates/internal/#disqus) available, to render it add the following code where you want comments to appear:
``` ```go-html-template
{{ template "_internal/disqus.html" . }} {{ template "_internal/disqus.html" . }}
``` ```
@ -55,9 +52,10 @@ These are some alternatives to Disqus:
* [Graph Comment](https://graphcomment.com/) * [Graph Comment](https://graphcomment.com/)
* [Hyvor Talk](https://talk.hyvor.com/) (Available as a service) * [Hyvor Talk](https://talk.hyvor.com/) (Available as a service)
* [IntenseDebate](https://intensedebate.com/) * [IntenseDebate](https://intensedebate.com/)
* [Isso](https://posativ.org/isso/) (Self-hosted, Python) ([tutorial][issotutorial]) * [Isso](https://isso-comments.de/) (Self-hosted, Python) ([tutorial][issotutorial])
* [Muut](https://muut.com/) * [Muut](https://muut.com/)
* [Remark42](https://remark42.com/) (Open source, Golang, Easy to run docker) * [Remark42](https://remark42.com/) (Open source, Golang, Easy to run docker)
* [ReplyBox](https://getreplybox.com/)
* [Staticman](https://staticman.net/) * [Staticman](https://staticman.net/)
* [Talkyard](https://blog-comments.talkyard.io/) (Open source, & serverless hosting) * [Talkyard](https://blog-comments.talkyard.io/) (Open source, & serverless hosting)
* [Utterances](https://utteranc.es/) (Open source, GitHub comments widget built on GitHub issues) * [Utterances](https://utteranc.es/) (Open source, GitHub comments widget built on GitHub issues)

View file

@ -1,31 +1,49 @@
--- ---
title: Links and Cross References title: Links and Cross References
linkTitle: Links and Cross References
description: Shortcodes for creating links to documents. description: Shortcodes for creating links to documents.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-03-31
categories: [content management] categories: [content management]
keywords: ["cross references","references", "anchors", "urls"] keywords: ["cross references","references", "anchors", "urls"]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 100 weight: 170
weight: 100 #rem
aliases: [/extras/crossreferences/]
toc: true toc: true
weight: 170
aliases: [/extras/crossreferences/]
--- ---
The `ref` and `relref` shortcodes display the absolute and relative permalinks to a document, respectively. The `ref` and `relref` shortcodes display the absolute and relative permalinks to a document, respectively.
## Use `ref` and `relref` ## Use of `ref` and `relref`
```go-html-template The `ref` and `relref` shortcodes require a single parameter: the path to a content document, with or without a file extension, with or without an anchor. Paths without a leading `/` are first resolved relative to the current page, then to the remainder of the site.
{{</* ref "document" */>}}
{{</* ref "document#anchor" */>}} ```
{{</* ref "document.md" */>}} .
{{</* ref "document.md#anchor" */>}} └── content
{{</* ref "#anchor" */>}} ├── about
{{</* ref "/blog/my-post" */>}} | ├── _index.md
| └── credits.md
├── pages
| ├── document1.md
| └── document2.md // has anchor #anchor
├── products
| └── index.md
└── blog
└── my-post.md
```
The pages can be referenced as follows:
```text
{{</* ref "document2" */>}} // <- From pages/document1.md, relative path
{{</* ref "document2#anchor" */>}}
{{</* ref "document2.md" */>}}
{{</* ref "document2.md#anchor" */>}}
{{</* ref "#anchor" */>}} // <- From pages/document2.md
{{</* ref "/blog/my-post" */>}} // <- From anywhere, absolute path
{{</* ref "/blog/my-post.md" */>}} {{</* ref "/blog/my-post.md" */>}}
{{</* relref "document" */>}} {{</* relref "document" */>}}
{{</* relref "document.md" */>}} {{</* relref "document.md" */>}}
@ -33,15 +51,22 @@ The `ref` and `relref` shortcodes display the absolute and relative permalinks t
{{</* relref "/blog/my-post.md" */>}} {{</* relref "/blog/my-post.md" */>}}
``` ```
To generate a hyperlink using `ref` or `relref` in markdown: index.md can be reference either by its path or by its containing folder without the ending `/`. \_index.md can be referenced only by its containing folder:
```md ```text
[About]({{</* ref "/page/about" */>}} "About Us") {{</* ref "/about" */>}} // <- References /about/_index.md
{{</* ref "/about/_index" */>}} // Raises REF_NOT_FOUND error
{{</* ref "/about/credits.md" */>}} // <- References /about/credits.md
{{</* ref "/products" */>}} // <- References /products/index.md
{{</* ref "/products/index" */>}} // <- References /products/index.md
``` ```
The `ref` and `relref` shortcodes require a single parameter: the path to a content document, with or without a file extension, with or without an anchor. To generate a hyperlink using `ref` or `relref` in markdown:
**Paths without a leading `/` are first resolved relative to the current page, then to the remainder of the site. ```text
[About]({{</* ref "/about" */>}} "About Us")
```
Hugo emits an error or warning if a document cannot be uniquely resolved. The error behavior is configurable; see below. Hugo emits an error or warning if a document cannot be uniquely resolved. The error behavior is configurable; see below.
@ -116,7 +141,7 @@ produces this HTML:
The behavior can, since Hugo 0.45, be configured in `config.toml`: The behavior can, since Hugo 0.45, be configured in `config.toml`:
refLinksErrorLevel ("ERROR") refLinksErrorLevel ("ERROR")
: When using `ref` or `relref` to resolve page links and a link cannot resolved, it will be logged with this log level. Valid values are `ERROR` (default) or `WARNING`. Any `ERROR` will fail the build (`exit -1`). : When using `ref` or `relref` to resolve page links and a link cannot resolved, it will be logged with this log level. Valid values are `ERROR` (default) or `WARNING`. Any `ERROR` will fail the build (`exit -1`).
refLinksNotFoundURL refLinksNotFoundURL

View file

@ -1,25 +1,23 @@
--- ---
title: Diagrams title: Diagrams
date: 2022-02-20 LinkTitle: Diagrams
description: Use fenced code blocks and markdown render hooks to display diagrams.
categories: [content management] categories: [content management]
keywords: [diagrams,drawing] keywords: [diagrams,drawing]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 22 weight: 50
weight: 22
toc: true toc: true
weight: 50
--- ---
{{< new-in "0.93.0" >}} {{< new-in "0.93.0" >}}
## GoAT Diagrams (Ascii) ## GoAT Diagrams (Ascii)
Hugo! supports [GoAT](https://github.com/bep/goat) natively. This means that this code block: Hugo supports [GoAT](https://github.com/bep/goat) natively. This means that this code block:
```` ````txt
```goat ```goat
. . . .--- 1 .-- 1 / 1 . . . .--- 1 .-- 1 / 1
/ \ | | .---+ .-+ + / \ | | .---+ .-+ +
@ -45,14 +43,9 @@ Will be rendered as:
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4 1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
``` ```
## Mermaid Diagrams ## Mermaid Diagrams
Hugo currently does not provide default templates for Mermaid diagrams. But you can easily add your own. One way to do it would be to create ` layouts/_default/_markup/render-codeblock-mermaid.html`: Hugo currently does not provide default templates for Mermaid diagrams. But you can easily add your own. One way to do it would be to create `layouts/_default/_markup/render-codeblock-mermaid.html`:
```go-html-template ```go-html-template
<div class="mermaid"> <div class="mermaid">
@ -61,7 +54,7 @@ Hugo currently does not provide default templates for Mermaid diagrams. But you
{{ .Page.Store.Set "hasMermaid" true }} {{ .Page.Store.Set "hasMermaid" true }}
``` ```
And then include this snippet at the bottom of the content template (below `.Content`): And then include this snippet at the bottom of the content template (**Note**: below `.Content` as the render hook is not processed until `.Content` is executed):
```go-html-template ```go-html-template
{{ if .Page.Store.Get "hasMermaid" }} {{ if .Page.Store.Get "hasMermaid" }}
@ -88,8 +81,6 @@ sequenceDiagram
Bob-->>John: Jolly good! Bob-->>John: Jolly good!
``` ```
## Goat Ascii Diagram Examples ## Goat Ascii Diagram Examples
### Graphics ### Graphics
@ -160,7 +151,7 @@ sequenceDiagram
### File tree ### File tree
Created from https://arthursonzogni.com/Diagon/#Tree Created from <https://arthursonzogni.com/Diagon/#Tree>
```goat { width=300 color="orange" } ```goat { width=300 color="orange" }
───Linux─┬─Android ───Linux─┬─Android
@ -176,7 +167,7 @@ Created from https://arthursonzogni.com/Diagon/#Tree
### Sequence Diagram ### Sequence Diagram
https://arthursonzogni.com/Diagon/#Sequence <https://arthursonzogni.com/Diagon/#Sequence>
```goat { class="w-40" } ```goat { class="w-40" }
┌─────┐ ┌───┐ ┌─────┐ ┌───┐
@ -197,7 +188,7 @@ https://arthursonzogni.com/Diagon/#Sequence
### Flowchart ### Flowchart
https://arthursonzogni.com/Diagon/#Flowchart <https://arthursonzogni.com/Diagon/#Flowchart>
```goat ```goat
_________________ _________________
@ -243,7 +234,7 @@ https://arthursonzogni.com/Diagon/#Flowchart
### Table ### Table
https://arthursonzogni.com/Diagon/#Table <https://arthursonzogni.com/Diagon/#Table>
```goat { class="w-80 dark-blue" } ```goat { class="w-80 dark-blue" }
┌────────────────────────────────────────────────┐ ┌────────────────────────────────────────────────┐
@ -272,6 +263,3 @@ https://arthursonzogni.com/Diagon/#Table
│LITERAL = """" character { character } """" .│ │LITERAL = """" character { character } """" .│
└────────────────────────────────────────────────┘ └────────────────────────────────────────────────┘
``` ```

View file

@ -1,19 +1,16 @@
--- ---
title: Content Formats title: Content Formats
linktitle: Content Formats linkTitle: Content Formats
description: Both HTML and Markdown are supported content formats. description: Both HTML and Markdown are supported content formats.
date: 2017-01-10
publishdate: 2017-01-10
categories: [content management] categories: [content management]
keywords: [markdown,asciidoc,pandoc,content format] keywords: [markdown,asciidoc,pandoc,content format]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 20 weight: 40
weight: 20 #rem
draft: false
aliases: [/content/markdown-extras/,/content/supported-formats/,/doc/supported-formats/]
toc: true toc: true
weight: 40
aliases: [/content/markdown-extras/,/content/supported-formats/,/doc/supported-formats/]
--- ---
You can put any file type into your `/content` directories, but Hugo uses the `markup` front matter value if set or the file extension (see `Markup identifiers` in the table below) to determine if the markup needs to be processed, e.g.: You can put any file type into your `/content` directories, but Hugo uses the `markup` front matter value if set or the file extension (see `Markup identifiers` in the table below) to determine if the markup needs to be processed, e.g.:
@ -28,7 +25,7 @@ The current list of content formats in Hugo:
| Name | Markup identifiers | Comment | | Name | Markup identifiers | Comment |
| ------------- | ------------- |-------------| | ------------- | ------------- |-------------|
| Goldmark | md, markdown, goldmark |Note that you can set the default handler of `md` and `markdown` to something else, see [Configure Markup](/getting-started/configuration-markup/).{{< new-in "0.60.0" >}} | | Goldmark | md, markdown, goldmark |Note that you can set the default handler of `md` and `markdown` to something else, see [Configure Markup](/getting-started/configuration-markup/).|
|Emacs Org-Mode|org|See [go-org](https://github.com/niklasfasching/go-org).| |Emacs Org-Mode|org|See [go-org](https://github.com/niklasfasching/go-org).|
|AsciiDoc|asciidocext, adoc, ad|Needs [Asciidoctor][ascii] installed.| |AsciiDoc|asciidocext, adoc, ad|Needs [Asciidoctor][ascii] installed.|
|RST|rst|Needs [RST](https://docutils.sourceforge.io/rst.html) installed.| |RST|rst|Needs [RST](https://docutils.sourceforge.io/rst.html) installed.|
@ -55,13 +52,13 @@ Because additional formats are external commands, generation performance will re
### External Helper AsciiDoc ### External Helper AsciiDoc
[AsciiDoc](https://github.com/asciidoc/asciidoc) implementation EOLs in Jan 2020 and is no longer supported. [AsciiDoc](https://github.com/asciidoc/asciidoc) implementation EOLs in Jan 2020 and is no longer supported.
AsciiDoc development is being continued under [Asciidoctor](https://github.com/asciidoctor). The format AsciiDoc AsciiDoc development is being continued under [Asciidoctor](https://github.com/asciidoctor). The format AsciiDoc
remains of course. Please continue with the implementation Asciidoctor. remains of course. Please continue with the implementation Asciidoctor.
### External Helper Asciidoctor ### External Helper Asciidoctor
The Asciidoctor community offers a wide set of tools for the AsciiDoc format that can be installed additionally to Hugo. The Asciidoctor community offers a wide set of tools for the AsciiDoc format that can be installed additionally to Hugo.
[See the Asciidoctor docs for installation instructions](https://asciidoctor.org/docs/install-toolchain/). Make sure that also all [See the Asciidoctor docs for installation instructions](https://asciidoctor.org/docs/install-toolchain/). Make sure that also all
optional extensions like `asciidoctor-diagram` or `asciidoctor-html5s` are installed if required. optional extensions like `asciidoctor-diagram` or `asciidoctor-html5s` are installed if required.
@ -100,7 +97,7 @@ Notice that for security concerns only extensions that do not have path separato
Example of how to set extensions and attributes: Example of how to set extensions and attributes:
``` ```yml
[markup.asciidocExt] [markup.asciidocExt]
extensions = ["asciidoctor-html5s", "asciidoctor-diagram"] extensions = ["asciidoctor-html5s", "asciidoctor-diagram"]
workingFolderCurrent = true workingFolderCurrent = true
@ -109,10 +106,10 @@ Example of how to set extensions and attributes:
my-attribute-name = "my value" my-attribute-name = "my value"
``` ```
In a complex Asciidoctor environment it is sometimes helpful to debug the exact call to your external helper with all In a complex Asciidoctor environment it is sometimes helpful to debug the exact call to your external helper with all
parameters. Run Hugo with `-v`. You will get an output like parameters. Run Hugo with `-v`. You will get an output like
``` ```txt
INFO 2019/12/22 09:08:48 Rendering book-as-pdf.adoc with C:\Ruby26-x64\bin\asciidoctor.bat using asciidoc args [--no-header-footer -r asciidoctor-html5s -b html5s -r asciidoctor-diagram --base-dir D:\prototypes\hugo_asciidoc_ddd\docs -a outdir=D:\prototypes\hugo_asciidoc_ddd\build -] ... INFO 2019/12/22 09:08:48 Rendering book-as-pdf.adoc with C:\Ruby26-x64\bin\asciidoctor.bat using asciidoc args [--no-header-footer -r asciidoctor-html5s -b html5s -r asciidoctor-diagram --base-dir D:\prototypes\hugo_asciidoc_ddd\docs -a outdir=D:\prototypes\hugo_asciidoc_ddd\build -] ...
``` ```

View file

@ -1,20 +1,17 @@
--- ---
title: Front Matter title: Front Matter
linktitle: linkTitle: Front Matter
description: Hugo allows you to add front matter in yaml, toml, or json to your content files. description: Hugo allows you to add front matter in yaml, toml, or json to your content files.
date: 2017-01-09
publishdate: 2017-01-09
lastmod: 2017-02-24 lastmod: 2017-02-24
categories: [content management] categories: [content management]
keywords: ["front matter", "yaml", "toml", "json", "metadata", "archetypes"] keywords: ["front matter", "yaml", "toml", "json", "metadata", "archetypes"]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 30 weight: 60
weight: 30 #rem
draft: false
aliases: [/content/front-matter/]
toc: true toc: true
weight: 60
aliases: [/content/front-matter/]
--- ---
**Front matter** allows you to keep metadata attached to an instance of a [content type][]---i.e., embedded inside a content file---and is one of the many features that gives Hugo its strength. **Front matter** allows you to keep metadata attached to an instance of a [content type][]---i.e., embedded inside a content file---and is one of the many features that gives Hugo its strength.
@ -68,7 +65,7 @@ cascade
: a map of Front Matter keys whose values are passed down to the page's descendants unless overwritten by self or a closer ancestor's cascade. See [Front Matter Cascade](#front-matter-cascade) for details. : a map of Front Matter keys whose values are passed down to the page's descendants unless overwritten by self or a closer ancestor's cascade. See [Front Matter Cascade](#front-matter-cascade) for details.
date date
: the datetime assigned to this page. This is usually fetched from the `date` field in front matter, but this behaviour is configurable. : the datetime assigned to this page. This is usually fetched from the `date` field in front matter, but this behavior is configurable.
description description
: the description for the content. : the description for the content.
@ -137,7 +134,7 @@ weight
: used for [ordering your content in lists][ordering]. Lower weight gets higher precedence. So content with lower weight will come first. If set, weights should be non-zero, as 0 is interpreted as an *unset* weight. : used for [ordering your content in lists][ordering]. Lower weight gets higher precedence. So content with lower weight will come first. If set, weights should be non-zero, as 0 is interpreted as an *unset* weight.
\<taxonomies\> \<taxonomies\>
: field name of the *plural* form of the index. See `tags` and `categories` in the above front matter examples. _Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables._ : field name of the *plural* form of the index. See `tags` and `categories` in the above front matter examples. *Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables.*
{{% note "Hugo's Default URL Destinations" %}} {{% note "Hugo's Default URL Destinations" %}}
If neither `slug` nor `url` is present and [permalinks are not configured otherwise in your site `config` file](/content-management/urls/#permalinks), Hugo will use the filename of your content to create the output URL. See [Content Organization](/content-management/organization) for an explanation of paths in Hugo and [URL Management](/content-management/urls/) for ways to customize Hugo's default behaviors. If neither `slug` nor `url` is present and [permalinks are not configured otherwise in your site `config` file](/content-management/urls/#permalinks), Hugo will use the filename of your content to create the output URL. See [Content Organization](/content-management/organization) for an explanation of paths in Hugo and [URL Management](/content-management/urls/) for ways to customize Hugo's default behaviors.
@ -160,9 +157,7 @@ Any node or section can pass down to descendants a set of Front Matter values as
### Target Specific Pages ### Target Specific Pages
{{< new-in "0.76.0" >}} The `cascade` block can be a slice with a optional `_target` keyword, allowing for multiple `cascade` values targeting different page sets.
Since Hugo 0.76 the `cascade` block can be a slice with a optional `_target` keyword, allowing for multiple `cascade` values targeting different page sets.
{{< code-toggle copy="false" >}} {{< code-toggle copy="false" >}}
title ="Blog" title ="Blog"
@ -181,7 +176,7 @@ kind="section"
Keywords available for `_target`: Keywords available for `_target`:
path path
: A [Glob](https://github.com/gobwas/glob) pattern matching the content path below /content. Expects Unix-styled slashes. Note that this is the virtual path, so it starts at the mount root. The matching support double-asterisks so you can match for patterns like `/blog/*/**` to match anything from the third level and down. : A [Glob](https://github.com/gobwas/glob) pattern matching the content path below /content. Expects Unix-styled slashes. Note that this is the virtual path, so it starts at the mount root. The matching supports double-asterisks so you can match for patterns like `/blog/*/**` to match anything from the third level and down.
kind kind
: A Glob pattern matching the Page's Kind(s), e.g. "{home,section}". : A Glob pattern matching the Page's Kind(s), e.g. "{home,section}".
@ -192,7 +187,7 @@ lang
environment environment
: A Glob pattern matching the build environment, e.g. "{production,development}" : A Glob pattern matching the build environment, e.g. "{production,development}"
Any of the above can be omitted. Any of the above can be omitted.
### Example ### Example
@ -206,11 +201,9 @@ cascade:
With the above example the Blog section page and its descendants will return `images/typewriter.jpg` when `.Params.banner` is invoked unless: With the above example the Blog section page and its descendants will return `images/typewriter.jpg` when `.Params.banner` is invoked unless:
- Said descendant has its own `banner` value set - Said descendant has its own `banner` value set
- Or a closer ancestor node has its own `cascade.banner` value set. - Or a closer ancestor node has its own `cascade.banner` value set.
## Order Content Through Front Matter ## Order Content Through Front Matter
You can assign content-specific `weight` in the front matter of your content. These values are especially useful for [ordering][ordering] in list views. You can use `weight` for ordering of content and the convention of [`<TAXONOMY>_weight`][taxweight] for ordering content within a taxonomy. See [Ordering and Grouping Hugo Lists][lists] to see how `weight` can be used to organize your content in list views. You can assign content-specific `weight` in the front matter of your content. These values are especially useful for [ordering][ordering] in list views. You can use `weight` for ordering of content and the convention of [`<TAXONOMY>_weight`][taxweight] for ordering content within a taxonomy. See [Ordering and Grouping Hugo Lists][lists] to see how `weight` can be used to organize your content in list views.
@ -221,9 +214,9 @@ It's possible to set some options for Markdown rendering in a content's front ma
## Front Matter Format Specs ## Front Matter Format Specs
* [TOML Spec][toml] - [TOML Spec][toml]
* [YAML Spec][yaml] - [YAML Spec][yaml]
* [JSON Spec][json] - [JSON Spec][json]
[variables]: /variables/ [variables]: /variables/
[aliases]: /content-management/urls/#aliases [aliases]: /content-management/urls/#aliases

View file

@ -1,16 +1,15 @@
--- ---
title: "Image Processing" title: Image Processing
description: "Resize, crop, rotate, filter, and convert images." linkTitle: Image Processing
date: 2018-01-24T13:10:00-05:00 description: Resize, crop, rotate, filter, and convert images.
categories: ["content management"] categories: [content management]
keywords: [resources, images] keywords: [resources, images]
weight: 4004
draft: false
toc: true
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 32 weight: 90
toc: true
weight: 90
--- ---
## Image Resources ## Image Resources
@ -28,16 +27,6 @@ content/
└── sunset.jpg <-- page resource └── sunset.jpg <-- page resource
``` ```
## The Image Resource
The `image` resource gives you access to image-specific attributes like the picture's `Width` and `Height`, as well as powerful processing methods and filters. More on that below.
Note that the `image` resource can also be retrieved from a [global resource]({{< relref "/hugo-pipes/introduction#from-file-to-resource" >}})
```go-html-template
{{ $image := .Resources.GetMatch "sunset.jpg" }}
```
### Global Resources ### Global Resources
A global resource is a file: A global resource is a file:
@ -94,10 +83,10 @@ Example 3: A more concise way to skip image rendering if the resource is not fou
## Image Processing Methods ## Image Processing Methods
The `image` resource implements the `Resize`, `Fit`, `Fill`, `Crop`, `Filter`, and `Exif` methods. The `image` resource implements the [`Resize`], [`Fit`], [`Fill`], [`Crop`], [`Filter`], [`Colors`] and [`Exif`] methods.
{{% note %}} {{% note %}}
Metadata (Exif, IPTC, XMP, etc.) is not preserved during image transformation. Use the`Exif` method with the _original_ image to extract Exif metadata from JPEG or TIFF images. Metadata (Exif, IPTC, XMP, etc.) is not preserved during image transformation. Use the [`Exif`] method with the _original_ image to extract Exif metadata from JPEG or TIFF images.
{{% /note %}} {{% /note %}}
### Resize ### Resize
@ -163,11 +152,24 @@ Sometimes it can be useful to create the filter chain once and then reuse it.
{{ $image2 := $image2.Filter $filters }} {{ $image2 := $image2.Filter $filters }}
``` ```
### Colors
{{< new-in "0.104.0" >}}
`.Colors` returns a slice of hex strings with the dominant colors in the image using a simple histogram method.
```go-html-template
{{ $colors := $image.Colors }}
```
This method is fast, but if you also scale down your images, it would be good for performance to extract the colors from the scaled down image.
### Exif ### Exif
Provides an [Exif] object containing image metadata. Provides an [Exif] object containing image metadata.
You may access Exif data in JPEG and TIFF images. To prevent errors when processing images without Exif data, wrap the access in a `with` statement. You may access Exif data in JPEG and TIFF images. To prevent errors when processing images without Exif data, wrap the access in a [`with`] statement.
```go-html-template ```go-html-template
{{ with $image.Exif }} {{ with $image.Exif }}
@ -213,11 +215,11 @@ You may also access Exif fields individually, using the [`lang.FormatNumber`] fu
## Image Processing Options ## Image Processing Options
The `Resize`, `Fit`, `Fill`, and `Crop` methods accept a space-separated, case-insensitive list of options. The order of the options within the list is irrelevant. The [`Resize`], [`Fit`], [`Fill`], and [`Crop`] methods accept a space-separated, case-insensitive list of options. The order of the options within the list is irrelevant.
### Dimensions ### Dimensions
With the `Resize` method you must specify width, height, or both. The `Fit`, `Fill`, and `Crop` methods require both width and height. All dimensions are in pixels. With the [`Resize`] method you must specify width, height, or both. The [`Fit`], [`Fill`], and [`Crop`] methods require both width and height. All dimensions are in pixels.
```go-html-template ```go-html-template
{{ $image := $image.Resize "600x" }} {{ $image := $image.Resize "600x" }}
@ -252,9 +254,9 @@ In the example above, on the second line, we have reversed width and height to r
### Anchor ### Anchor
When using the `Crop` or `Fill` method, the _anchor_ determines the placement of the crop box. You may specify `TopLeft`, `Top`, `TopRight`, `Left`, `Center`,`Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`. When using the [`Crop`] or [`Fill`] method, the _anchor_ determines the placement of the crop box. You may specify `TopLeft`, `Top`, `TopRight`, `Left`, `Center`,`Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`.
The default value is `Smart`, which uses [Smartcrop] image analysis to determine the optimal placement of the crop box. You may override the default value in the [site configuration](#processing-options). The default value is `Smart`, which uses [Smartcrop] image analysis to determine the optimal placement of the crop box. You may override the default value in the [site configuration].
For example, if you have a 400x200 image with a bird in the upper left quadrant, you can create a 200x100 thumbnail containing the bird: For example, if you have a 400x200 image with a bird in the upper left quadrant, you can create a 200x100 thumbnail containing the bird:
@ -262,7 +264,7 @@ For example, if you have a 400x200 image with a bird in the upper left quadrant,
{{ $image.Crop "200x100 TopLeft" }} {{ $image.Crop "200x100 TopLeft" }}
``` ```
If you apply rotation when using the `Crop` or `Fill` method, specify the anchor relative to the rotated image. If you apply [rotation](#rotation) when using the [`Crop`] or [`Fill`] method, specify the anchor relative to the rotated image.
### Target Format ### Target Format
@ -286,7 +288,7 @@ To convert an image without scaling, use the dimensions of the original image:
Applicable to JPEG and WebP images, the `q` value determines the quality of the converted image. Higher values produce better quality images, while lower values produce smaller files. Set this value to a whole number between 1 and 100, inclusive. Applicable to JPEG and WebP images, the `q` value determines the quality of the converted image. Higher values produce better quality images, while lower values produce smaller files. Set this value to a whole number between 1 and 100, inclusive.
The default value is 75. You may override the default value in the [site configuration](#processing-options). The default value is 75. You may override the default value in the [site configuration].
```go-html-template ```go-html-template
{{ $image.Resize "600x webp q50" }} {{ $image.Resize "600x webp q50" }}
@ -296,7 +298,7 @@ The default value is 75. You may override the default value in the [site configu
<!-- Specifies a libwebp preset, not a libwebp image hint. --> <!-- Specifies a libwebp preset, not a libwebp image hint. -->
Applicable to WebP images, this option corresponds to a set of pre-defined encoding parameters. Applicable to WebP images, this option corresponds to a set of predefined encoding parameters.
Value|Example Value|Example
:--|:-- :--|:--
@ -306,7 +308,7 @@ Value|Example
`picture`|Indoor photograph such as a portrait `picture`|Indoor photograph such as a portrait
`text`|Image that is primarily text `text`|Image that is primarily text
The default value is `photo`. You may override the default value in the [site configuration](#processing-options). The default value is `photo`. You may override the default value in the [site configuration].
```go-html-template ```go-html-template
{{ $image.Resize "600x webp picture" }} {{ $image.Resize "600x webp picture" }}
@ -318,7 +320,7 @@ When converting an image from a format that supports transparency (e.g., PNG) to
Use either a 3-digit or a 6-digit hexadecimal color code (e.g., `#00f` or `#0000ff`). Use either a 3-digit or a 6-digit hexadecimal color code (e.g., `#00f` or `#0000ff`).
The default value is `#ffffff` (white). You may override the default value in the [site configuration](#processing-options). The default value is `#ffffff` (white). You may override the default value in the [site configuration].
```go-html-template ```go-html-template
{{ $image.Resize "600x jpg #b31280" }} {{ $image.Resize "600x jpg #b31280" }}
@ -337,7 +339,7 @@ Filter|Description
`Linear`|Bilinear resampling filter, produces smooth output, faster than cubic filters `Linear`|Bilinear resampling filter, produces smooth output, faster than cubic filters
`NearestNeighbor`|Fastest resampling filter, no antialiasing `NearestNeighbor`|Fastest resampling filter, no antialiasing
The default value is `Box`. You may override the default value in the [site configuration](#processing-options). The default value is `Box`. You may override the default value in the [site configuration].
```go-html-template ```go-html-template
{{ $image.Resize "600x400 Lanczos" }} {{ $image.Resize "600x400 Lanczos" }}
@ -364,10 +366,10 @@ _The photo of the sunset used in the examples below is Copyright [Bjørn Erik Pe
This is the shortcode used to generate the examples above: This is the shortcode used to generate the examples above:
{{< code file="layouts/shortcodes/imgproc.html" >}} {{< code file="layouts/shortcodes/imgproc.html" >}}
{{< readfile file="layouts/shortcodes/imgproc.html" >}} {{< readfile file="layouts/shortcodes/imgproc.html" >}}
{{< /code >}} {{< /code >}}
Call the shortcode from your markdown like this: Call the shortcode from your Markdown like this:
```go-html-template ```go-html-template
{{</* imgproc sunset Resize "300x" /*/>}} {{</* imgproc sunset Resize "300x" /*/>}}
@ -464,3 +466,12 @@ hugo --gc
[page bundle]: {{< relref "content-management/page-bundles" >}} [page bundle]: {{< relref "content-management/page-bundles" >}}
[Smartcrop]: <https://github.com/muesli/smartcrop#smartcrop> [Smartcrop]: <https://github.com/muesli/smartcrop#smartcrop>
[time.Format]: {{< relref "functions/dateformat" >}} [time.Format]: {{< relref "functions/dateformat" >}}
[`Colors`]: #colors
[`Crop`]: #crop
[`Exif`]: #exif
[`Fill`]: #fill
[`Filter`]: #filter
[`Fit`]: #fit
[`Resize`]: #resize
[site configuration]: #processing-options
[`with`]: /functions/with/

View file

@ -1,20 +1,16 @@
--- ---
title: Menus title: Menus
linktitle: Menus linkTitle: Menus
description: Hugo has a simple yet powerful menu system. description: Hugo has a simple yet powerful menu system.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-03-31
categories: [content management] categories: [content management]
keywords: [menus] keywords: [menus]
draft: false
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 120 weight: 190
weight: 120
aliases: [/extras/menus/]
toc: true toc: true
weight: 190
aliases: [/extras/menus/]
--- ---
{{% note "Lazy Blogger"%}} {{% note "Lazy Blogger"%}}
@ -69,7 +65,7 @@ menu:
## Add Non-content Entries to a Menu ## Add Non-content Entries to a Menu
You can also add entries to menus that arent attached to a piece of content. This takes place in your Hugo project's [`config` file][config]. You can also add entries to menus that arent attached to a piece of content. This takes place in your Hugo project's [`config` file][config] (see [Menu Entry Properties][me-props] for full details of available variables).
Heres an example snippet pulled from a configuration file: Heres an example snippet pulled from a configuration file:

View file

@ -1,19 +1,16 @@
--- ---
title: Multilingual Mode title: Multilingual Mode
linktitle: Multilingual 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
publishdate: 2017-01-10
categories: [content management] categories: [content management]
keywords: [multilingual,i18n, internationalization] keywords: [multilingual,i18n, internationalization]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 150 weight: 230
weight: 150 #rem
draft: false
aliases: [/content/multilingual/,/tutorials/create-a-multilingual-site/]
toc: true toc: true
weight: 230
aliases: [/content/multilingual/,/tutorials/create-a-multilingual-site/]
--- ---
You should define the available languages in a `languages` section in your site configuration. You should define the available languages in a `languages` section in your site configuration.
@ -59,7 +56,7 @@ weight = 3
Anything not defined in a `languages` block will fall back to the global value for that key (e.g., `copyright` for the English `en` language). This also works for `params`, as demonstrated with `help` above: You will get the value `Aide` in French and `Help` in all the languages without this parameter set. Anything not defined in a `languages` block will fall back to the global value for that key (e.g., `copyright` for the English `en` language). This also works for `params`, as demonstrated with `help` above: You will get the value `Aide` in French and `Help` in all the languages without this parameter set.
With the configuration above, all content, sitemap, RSS feeds, paginations, With the configuration above, all content, sitemap, RSS feeds, pagination,
and taxonomy pages will be rendered below `/` in English (your default content language) and then below `/fr` in French. and taxonomy pages will be rendered below `/` in English (your default content language) and then below `/fr` in French.
When working with front matter `Params` in [single page templates], omit the `params` in the key for the translation. When working with front matter `Params` in [single page templates], omit the `params` in the key for the translation.
@ -229,7 +226,7 @@ If using `url`, remember to include the language part as well: `/fr/compagnie/a-
### Page Bundles ### Page Bundles
To avoid the burden of having to duplicate files, each Page Bundle inherits the resources of its linked translated pages' bundles except for the content files (markdown files, html files etc...). To avoid the burden of having to duplicate files, each Page Bundle inherits the resources of its linked translated pages' bundles except for the content files (Markdown files, HTML files etc...).
Therefore, from within a template, the page will have access to the files from all linked pages' bundles. Therefore, from within a template, the page will have access to the files from all linked pages' bundles.
@ -507,6 +504,7 @@ The rendering of the main navigation works as usual. `.Site.Menus` will just con
``` ```
### Dynamically localizing menus with i18n ### Dynamically localizing menus with i18n
While customizing menus per language is useful, your config file can become hard to maintain if you have a lot of languages While customizing menus per language is useful, your config file can become hard to maintain if you have a lot of languages
If your menus are the same in all languages (ie. if the only thing that changes is the translated name) you can use the `.Identifier` as a translation key for the menu name: If your menus are the same in all languages (ie. if the only thing that changes is the translated name) you can use the `.Identifier` as a translation key for the menu name:
@ -538,7 +536,6 @@ And do the appropriate changes in the menu code to use the `i18n` tag with the `
{{- end }} {{- end }}
</ul> </ul>
{{< /code >}} {{< /code >}}
## Missing Translations ## Missing Translations
@ -570,9 +567,8 @@ If there is more than one language defined, the `LanguagePrefix` variable will e
## Generate multilingual content with `hugo new` ## Generate multilingual content with `hugo new`
Currently, `hugo new` is not ready to support generating multilingual content. But there is a [proposal topic](https://github.com/gohugoio/hugo/issues/7732) about this in Github issue to discuss how it should work.
Currently, `hugo new` is not ready to support generating multilingual content. But there is a [proposal topic](https://github.com/gohugoio/hugo/issues/7732) about this in GitHub issue to discuss how it should work.
[abslangurl]: /functions/abslangurl [abslangurl]: /functions/abslangurl
[config]: /getting-started/configuration/ [config]: /getting-started/configuration/

View file

@ -1,20 +1,16 @@
--- ---
title: Content Organization title: Content Organization
linktitle: Organization linkTitle: Organization
description: Hugo assumes that the same structure that works to organize your source content is used to organize the rendered site. description: Hugo assumes that the same structure that works to organize your source content is used to organize the rendered site.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [content management,fundamentals] categories: [content management,fundamentals]
keywords: [sections,content,organization,bundle,resources] keywords: [sections,content,organization,bundle,resources]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 10 weight: 20
weight: 10 #rem
draft: false
aliases: [/content/sections/]
toc: true toc: true
weight: 20
aliases: [/content/sections/]
--- ---
## Page Bundles ## Page Bundles
@ -35,14 +31,13 @@ The bundle documentation is a **work in progress**. We will publish more compreh
## Organization of Content Source ## Organization of Content Source
In Hugo, your content should be organized in a manner that reflects the rendered website. In Hugo, your content should be organized in a manner that reflects the rendered website.
While Hugo supports content nested at any level, the top levels (i.e. `content/<DIRECTORIES>`) are special in Hugo and are considered the content type used to determine layouts etc. To read more about sections, including how to nest them, see [sections][]. While Hugo supports content nested at any level, the top levels (i.e. `content/<DIRECTORIES>`) are special in Hugo and are considered the content type used to determine layouts etc. To read more about sections, including how to nest them, see [sections][].
Without any additional configuration, the following will automatically work: Without any additional configuration, the following will automatically work:
``` ```txt
. .
└── content └── content
└── about └── about
@ -73,7 +68,7 @@ The following demonstrates the relationships between your content organization a
You can create one `_index.md` for your homepage and one in each of your content sections, taxonomies, and taxonomy terms. The following shows typical placement of an `_index.md` that would contain content and front matter for a `posts` section list page on a Hugo website: You can create one `_index.md` for your homepage and one in each of your content sections, taxonomies, and taxonomy terms. The following shows typical placement of an `_index.md` that would contain content and front matter for a `posts` section list page on a Hugo website:
``` ```txt
. url . url
. ⊢--^-⊣ . ⊢--^-⊣
. path slug . path slug
@ -85,7 +80,7 @@ content/posts/_index.md
At build, this will output to the following destination with the associated values: At build, this will output to the following destination with the associated values:
``` ```txt
url ("/posts/") url ("/posts/")
⊢-^-⊣ ⊢-^-⊣
@ -104,7 +99,7 @@ The [sections] can be nested as deeply as you want. The important thing to under
Single content files in each of your sections will be rendered as [single page templates][singles]. Here is an example of a single `post` within `posts`: Single content files in each of your sections will be rendered as [single page templates][singles]. Here is an example of a single `post` within `posts`:
``` ```txt
path ("posts/my-first-hugo-post.md") path ("posts/my-first-hugo-post.md")
. ⊢-----------^------------⊣ . ⊢-----------^------------⊣
. section slug . section slug
@ -114,7 +109,7 @@ content/posts/my-first-hugo-post.md
When Hugo builds your site, the content will be output to the following destination: When Hugo builds your site, the content will be output to the following destination:
``` ```txt
url ("/posts/my-first-hugo-post/") url ("/posts/my-first-hugo-post/")
⊢------------^----------⊣ ⊢------------^----------⊣
@ -180,7 +175,7 @@ slug: "new-post"
This will render to the following destination according to Hugo's default behavior: This will render to the following destination according to Hugo's default behavior:
``` ```txt
example.com/posts/new-post/ example.com/posts/new-post/
``` ```
@ -217,7 +212,7 @@ url: /blog/new-url/
Assuming your `baseURL` is [configured][config] to `https://example.com`, the addition of `url` to the front matter will make `old-url.md` render to the following destination: Assuming your `baseURL` is [configured][config] to `https://example.com`, the addition of `url` to the front matter will make `old-url.md` render to the following destination:
``` ```txt
https://example.com/blog/new-url/ https://example.com/blog/new-url/
``` ```

View file

@ -1,16 +1,17 @@
--- ---
title : "Page Bundles" title: Page Bundles
description : "Content organization using Page Bundles" linkTitle: Page Bundles
date : 2018-01-24T13:09:00-05:00 description: Content organization using Page Bundles
linktitle : "Page Bundles" linkTitle: Page Bundles
keywords : ["page", "bundle", "leaf", "branch"] keywords: [page, bundle, leaf, branch]
categories : ["content management"] categories: [content management]
toc : true
menu : menu :
docs: docs:
identifier : "page-bundles" identifier: "page-bundles"
parent : "content-management" parent: "content-management"
weight : 11 weight: 30
toc: true
weight: 30
--- ---
Page Bundles are a way to group [Page Resources](/content-management/page-resources/). Page Bundles are a way to group [Page Resources](/content-management/page-resources/).
@ -23,8 +24,8 @@ A Page Bundle can be one of:
| | Leaf Bundle | Branch Bundle | | | Leaf Bundle | Branch Bundle |
|-------------------------------------|----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |-------------------------------------|----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Usage | Collection of content and attachments for single pages | Collection of attachments for section pages (home page, section, taxonomy terms, taxonomy list) | | Usage | Collection of content and attachments for single pages | Collection of attachments for section pages (home page, section, taxonomy terms, taxonomy list) |
| Index file name | `index.md` [^fn:1] | `_index.md` [^fn:1] | | Index filename | `index.md` [^fn:1] | `_index.md` [^fn:1] |
| Allowed Resources | Page and non-page (like images, pdf, etc.) types | Only non-page (like images, pdf, etc.) types | | Allowed Resources | Page and non-page (like images, PDF, etc.) types | Only non-page (like images, PDF, etc.) types |
| Where can the Resources live? | At any directory level within the leaf bundle directory. | Only in the directory level **of** the branch bundle directory i.e. the directory containing the `_index.md` ([ref](https://discourse.gohugo.io/t/question-about-content-folder-structure/11822/4?u=kaushalmodi)). | | Where can the Resources live? | At any directory level within the leaf bundle directory. | Only in the directory level **of** the branch bundle directory i.e. the directory containing the `_index.md` ([ref](https://discourse.gohugo.io/t/question-about-content-folder-structure/11822/4?u=kaushalmodi)). |
| Layout type | `single` | `list` | | Layout type | `single` | `list` |
| Nesting | Does not allow nesting of more bundles under it | Allows nesting of leaf or branch bundles under it | | Nesting | Does not allow nesting of more bundles under it | Allows nesting of leaf or branch bundles under it |
@ -72,13 +73,13 @@ bundles:
: This leaf bundle has the `index.md`, two other content : This leaf bundle has the `index.md`, two other content
Markdown files and two image files. Markdown files and two image files.
- image1, image2: - image1, image2:
These images are page resources of `my-post` These images are page resources of `my-post`
and only available in `my-post/index.md` resources. and only available in `my-post/index.md` resources.
- content1, content2: - content1, content2:
These content files are page resources of `my-post` These content files are page resources of `my-post`
and only available in `my-post/index.md` resources. and only available in `my-post/index.md` resources.
They will **not** be rendered as individual pages. They will **not** be rendered as individual pages.
`my-other-post` `my-other-post`
@ -99,8 +100,8 @@ as long as it is not inside another **leaf** bundle.
A headless bundle is a bundle that is configured to not get published A headless bundle is a bundle that is configured to not get published
anywhere: anywhere:
- It will have no `Permalink` and no rendered HTML in `public/`. - It will have no `Permalink` and no rendered HTML in `public/`.
- It will not be part of `.Site.RegularPages`, etc. - It will not be part of `.Site.RegularPages`, etc.
But you can get it by `.Site.GetPage`. Here is an example: But you can get it by `.Site.GetPage`. Here is an example:
@ -121,9 +122,9 @@ _In this example, we are assuming the `some-headless-bundle` to be a headless
Explanation of the above example: Explanation of the above example:
1. Get the `some-headless-bundle` Page "object". 1. Get the `some-headless-bundle` Page "object".
2. Collect a *slice* of resources in this *Page Bundle* that matches 2. Collect a _slice_ of resources in this _Page Bundle_ that matches
`"author*"` using `.Resources.Match`. `"author*"` using `.Resources.Match`.
3. Loop through that *slice* of nested pages, and output their `.Title` and 3. Loop through that _slice_ of nested pages, and output their `.Title` and
`.Content`. `.Content`.
--- ---
@ -137,9 +138,8 @@ headless = true
There are many use cases of such headless page bundles: There are many use cases of such headless page bundles:
- Shared media galleries - Shared media galleries
- Reusable page content "snippets" - Reusable page content "snippets"
## Branch Bundles {#branch-bundles} ## Branch Bundles {#branch-bundles}

View file

@ -1,17 +1,15 @@
--- ---
title : "Page Resources" title: Page Resources
description : "Page resources -- images, other pages, documents, etc. -- have page-relative URLs and their own metadata." linkTitle: Page Resources
date: 2018-01-24 description: Page resources -- images, other pages, documents, etc. -- have page-relative URLs and their own metadata.
categories: ["content management"] categories: [content management]
keywords: [bundle,content,resources] keywords: [bundle,content,resources]
weight: 4003
draft: false
toc: true
linktitle: "Page Resources"
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 31 weight: 80
toc: true
weight: 80
--- ---
Page resources are only accessible from [page bundles]({{< relref Page resources are only accessible from [page bundles]({{< relref
"/content-management/page-bundles" >}}), those directories with `index.md` or "/content-management/page-bundles" >}}), those directories with `index.md` or
@ -45,8 +43,6 @@ content
ResourceType ResourceType
: The main type of the resource's [Media Type](/templates/output-formats/#media-types). For example, a file of MIME type `image/jpeg` has the ResourceType `image`. A `Page` will have `ResourceType` with value `page`. : The main type of the resource's [Media Type](/templates/output-formats/#media-types). For example, a file of MIME type `image/jpeg` has the ResourceType `image`. A `Page` will have `ResourceType` with value `page`.
{{< new-in "0.80.0" >}} Note that we in Hugo `v0.80.0` fixed a bug where non-image resources (e.g. video) would return the MIME sub type, e.g. `json`.
Name Name
: Default value is the filename (relative to the owning page). Can be set in front matter. : Default value is the filename (relative to the owning page). Can be set in front matter.
@ -90,16 +86,17 @@ MediaType.Suffixes
: A slice of possible suffixes for the resource's MIME type. : A slice of possible suffixes for the resource's MIME type.
## Methods ## Methods
ByType ByType
: Returns the page resources of the given type. : Returns the page resources of the given type.
```go ```go-html-template
{{ .Resources.ByType "image" }} {{ .Resources.ByType "image" }}
``` ```
Match Match
: Returns all the page resources (as a slice) whose `Name` matches the given Glob pattern ([examples](https://github.com/gobwas/glob/blob/master/readme.md)). The matching is case-insensitive. : Returns all the page resources (as a slice) whose `Name` matches the given Glob pattern ([examples](https://github.com/gobwas/glob/blob/master/readme.md)). The matching is case-insensitive.
```go ```go-html-template
{{ .Resources.Match "images/*" }} {{ .Resources.Match "images/*" }}
``` ```
@ -107,6 +104,7 @@ GetMatch
: Same as `Match` but will return the first match. : Same as `Match` but will return the first match.
### Pattern Matching ### Pattern Matching
```go ```go
// Using Match/GetMatch to find this images/sunset.jpg ? // Using Match/GetMatch to find this images/sunset.jpg ?
.Resources.Match "images/sun*" ✅ .Resources.Match "images/sun*" ✅
@ -140,8 +138,7 @@ title
params params
: A map of custom key/values. : A map of custom key/values.
### Resources metadata example
### Resources metadata example
{{< code-toggle copy="false">}} {{< code-toggle copy="false">}}
title: Application title: Application

View file

@ -1,25 +1,22 @@
--- ---
title: Related Content title: Related Content
linkTitle: Related Content
description: List related content in "See Also" sections. description: List related content in "See Also" sections.
date: 2017-09-05
categories: [content management] categories: [content management]
keywords: [content] keywords: [content]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 40 weight: 110
weight: 30
draft: false
aliases: [/content/related/,/related/]
toc: true toc: true
weight: 110
aliases: [/content/related/,/related/]
--- ---
Hugo uses a set of factors to identify a page's related content based on Front Matter parameters. This can be tuned to the desired set of indices and parameters or left to Hugo's default [Related Content configuration](#configure-related-content). Hugo uses a set of factors to identify a page's related content based on Front Matter parameters. This can be tuned to the desired set of indices and parameters or left to Hugo's default [Related Content configuration](#configure-related-content).
## List Related Content ## List Related Content
To list up to 5 related pages (which share the same _date_ or _keyword_ parameters) is as simple as including something similar to this partial in your single page template: To list up to 5 related pages (which share the same _date_ or _keyword_ parameters) is as simple as including something similar to this partial in your single page template:
{{< code file="layouts/partials/related.html" >}} {{< code file="layouts/partials/related.html" >}}
@ -27,9 +24,9 @@ To list up to 5 related pages (which share the same _date_ or _keyword_ paramete
{{ with $related }} {{ with $related }}
<h3>See Also</h3> <h3>See Also</h3>
<ul> <ul>
{{ range . }} {{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li> <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }} {{ end }}
</ul> </ul>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
@ -39,25 +36,28 @@ To list up to 5 related pages (which share the same _date_ or _keyword_ paramete
Here is the list of "Related" methods available on a page collection such `.RegularPages`. Here is the list of "Related" methods available on a page collection such `.RegularPages`.
#### .Related PAGE #### .Related PAGE
Returns a collection of pages related the given one. Returns a collection of pages related the given one.
``` ```go-html-template
{{ $related := site.RegularPages.Related . }} {{ $related := site.RegularPages.Related . }}
``` ```
#### .RelatedIndices PAGE INDICE1 [INDICE2 ...] #### .RelatedIndices PAGE INDICE1 [INDICE2 ...]
Returns a collection of pages related to a given one restricted to a list of indices. Returns a collection of pages related to a given one restricted to a list of indices.
``` ```go-html-template
{{ $related := site.RegularPages.RelatedIndices . "tags" "date" }} {{ $related := site.RegularPages.RelatedIndices . "tags" "date" }}
``` ```
#### .RelatedTo KEYVALS [KEYVALS2 ...] #### .RelatedTo KEYVALS [KEYVALS2 ...]
Returns a collection of pages related together by a set of indices and their match. Returns a collection of pages related together by a set of indices and their match.
In order to build those set and pass them as argument, one must use the `keyVals` function where the first argument would be the `indice` and the consecutive ones its potential `matches`. In order to build those set and pass them as argument, one must use the `keyVals` function where the first argument would be the `indice` and the consecutive ones its potential `matches`.
``` ```go-html-template
{{ $related := site.RegularPages.RelatedTo ( keyVals "tags" "hugo" "rocks") ( keyVals "date" .Date ) }} {{ $related := site.RegularPages.RelatedTo ( keyVals "tags" "hugo" "rocks") ( keyVals "date" .Date ) }}
``` ```
@ -66,6 +66,7 @@ Read [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-r
{{% /note %}} {{% /note %}}
## Configure Related Content ## Configure Related Content
Hugo provides a sensible default configuration of Related Content, but you can fine-tune this in your configuration, on the global or language level if needed. Hugo provides a sensible default configuration of Related Content, but you can fine-tune this in your configuration, on the global or language level if needed.
### Default configuration ### Default configuration

View file

@ -1,7 +1,7 @@
--- ---
title: Content Sections title: Content Sections
linktitle: Sections linkTitle: Sections
description: "Hugo generates a **section tree** that matches your content." description: Hugo generates a **section tree** that matches your content.
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2017-02-01
@ -9,12 +9,11 @@ categories: [content management]
keywords: [lists,sections,content types,organization] keywords: [lists,sections,content types,organization]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 50 weight: 120
weight: 50 #rem
draft: false
aliases: [/content/sections/]
toc: true toc: true
weight: 120
aliases: [/content/sections/]
--- ---
A **Section** is a collection of pages that gets defined based on the A **Section** is a collection of pages that gets defined based on the
@ -73,7 +72,7 @@ With the available [section variables and methods](#section-page-variables-and-m
{{ else if not .p1.IsHome }} {{ else if not .p1.IsHome }}
{{ template "breadcrumbnav" (dict "p1" .p1.Site.Home "p2" .p2 ) }} {{ template "breadcrumbnav" (dict "p1" .p1.Site.Home "p2" .p2 ) }}
{{ end }} {{ end }}
<li{{ if eq .p1 .p2 }} class="active"{{ end }}> <li{{ if eq .p1 .p2 }} class="active" aria-current="page" {{ end }}>
<a href="{{ .p1.Permalink }}">{{ .p1.Title }}</a> <a href="{{ .p1.Permalink }}">{{ .p1.Title }}</a>
</li> </li>
{{ end }} {{ end }}
@ -87,7 +86,7 @@ Also see [Page Variables](/variables/page/).
## Content Section Lists ## Content Section Lists
Hugo will automatically create pages for each *root section* that list all of the content in that section. See the documentation on [section templates][] for details on customizing the way these pages are rendered. Hugo will automatically create a page for each *root section* that lists all the content in that section. See the documentation on [section templates][] for details on customizing the way these pages are rendered.
## Content *Section* vs Content *Type* ## Content *Section* vs Content *Type*

View file

@ -1,21 +1,17 @@
--- ---
title: Shortcodes title: Shortcodes
linktitle: linkTitle: Shortcodes
description: Shortcodes are simple snippets inside your content files calling built-in or custom templates. description: Shortcodes are simple snippets inside your content files calling built-in or custom templates.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2019-11-07
menu:
docs:
parent: "content-management"
weight: 35
weight: 35 #rem
categories: [content management] categories: [content management]
keywords: [markdown,content,shortcodes] keywords: [markdown,content,shortcodes]
draft: false menu:
docs:
parent: content-management
weight: 100
toc: true
weight: 100
aliases: [/extras/shortcodes/] aliases: [/extras/shortcodes/]
testparam: "Hugo Rocks!" testparam: "Hugo Rocks!"
toc: true
--- ---
## What a Shortcode is ## What a Shortcode is
@ -40,11 +36,11 @@ Some shortcodes use or require closing shortcodes. Again like HTML, the opening
Here are two examples of paired shortcodes: Here are two examples of paired shortcodes:
``` ```go-html-template
{{%/* mdshortcode */%}}Stuff to `process` in the *center*.{{%/* /mdshortcode */%}} {{%/* mdshortcode */%}}Stuff to `process` in the *center*.{{%/* /mdshortcode */%}}
``` ```
``` ```go-html-template
{{</* highlight go */>}} A bunch of code here {{</* /highlight */>}} {{</* highlight go */>}} A bunch of code here {{</* /highlight */>}}
``` ```
@ -52,11 +48,9 @@ The examples above use two different delimiters, the difference being the `%` ch
### Shortcodes with raw string parameters ### Shortcodes with raw string parameters
{{< new-in "0.64.1" >}}
You can pass multiple lines as parameters to a shortcode by using raw string literals: You can pass multiple lines as parameters to a shortcode by using raw string literals:
``` ```go-html-template
{{</* myshortcode `This is some <b>HTML</b>, {{</* myshortcode `This is some <b>HTML</b>,
and a new line with a "quoted string".` */>}} and a new line with a "quoted string".` */>}}
``` ```
@ -67,16 +61,15 @@ In Hugo `0.55` we changed how the `%` delimiter works. Shortcodes using the `%`
If you want the old behavior, you can put the following line in the start of your shortcode template: If you want the old behavior, you can put the following line in the start of your shortcode template:
``` ```go-html-template
{{ $_hugo_config := `{ "version": 1 }` }} {{ $_hugo_config := `{ "version": 1 }` }}
``` ```
### Shortcodes Without Markdown ### Shortcodes Without Markdown
The `<` character indicates that the shortcode's inner content does *not* need further rendering. Often shortcodes without markdown include internal HTML: The `<` character indicates that the shortcode's inner content does *not* need further rendering. Often shortcodes without Markdown include internal HTML:
``` ```go-html-template
{{</* myshortcode */>}}<p>Hello <strong>World!</strong></p>{{</* /myshortcode */>}} {{</* myshortcode */>}}<p>Hello <strong>World!</strong></p>{{</* /myshortcode */>}}
``` ```
@ -86,11 +79,11 @@ You can call shortcodes within other shortcodes by creating your own templates t
## Use Hugo's Built-in Shortcodes ## Use Hugo's Built-in Shortcodes
Hugo ships with a set of predefined shortcodes that represent very common usage. These shortcodes are provided for author convenience and to keep your markdown content clean. Hugo ships with a set of predefined shortcodes that represent very common usage. These shortcodes are provided for author convenience and to keep your Markdown content clean.
### `figure` ### `figure`
`figure` is an extension of the image syntax in markdown, which does not provide a shorthand for the more semantic [HTML5 `<figure>` element][figureelement]. `figure` is an extension of the image syntax in Markdown, which does not provide a shorthand for the more semantic [HTML5 `<figure>` element][figureelement].
The `figure` shortcode can use the following named parameters: The `figure` shortcode can use the following named parameters:
@ -151,13 +144,13 @@ attrlink
Bloggers often want to include GitHub gists when writing posts. Let's suppose we want to use the [gist at the following url][examplegist]: Bloggers often want to include GitHub gists when writing posts. Let's suppose we want to use the [gist at the following url][examplegist]:
``` ```txt
https://gist.github.com/spf13/7896402 https://gist.github.com/spf13/7896402
``` ```
We can embed the gist in our content via username and gist ID pulled from the URL: We can embed the gist in our content via username and gist ID pulled from the URL:
``` ```go-html-template
{{</* gist spf13 7896402 */>}} {{</* gist spf13 7896402 */>}}
``` ```
@ -177,7 +170,7 @@ If the gist contains several files and you want to quote just one of them, you c
#### Example `gist` Display #### Example `gist` Display
To demonstrate the remarkably efficiency of Hugo's shortcode feature, we have embedded the `spf13` `gist` example in this page. The following simulates the experience for visitors to your website. Naturally, the final display will be contingent on your stylesheets and surrounding markup. To demonstrate the remarkable efficiency of Hugo's shortcode feature, we have embedded the `spf13` `gist` example in this page. The following simulates the experience for visitors to your website. Naturally, the final display will depend on your stylesheets and surrounding markup.
{{< gist spf13 7896402 >}} {{< gist spf13 7896402 >}}
@ -223,7 +216,7 @@ To see even more options for adding syntax-highlighted code blocks to your websi
If you'd like to embed a photo from [Instagram][], you only need the photo's ID. You can discern an Instagram photo ID from the URL: If you'd like to embed a photo from [Instagram][], you only need the photo's ID. You can discern an Instagram photo ID from the URL:
``` ```txt
https://www.instagram.com/p/BWNjjyYFxVx/ https://www.instagram.com/p/BWNjjyYFxVx/
``` ```
@ -249,19 +242,18 @@ By adding the preceding `hidecaption` example, the following HTML will be added
#### Example `instagram` Display #### Example `instagram` Display
Using the preceding `instagram` with `hidecaption` example above, the following simulates the displayed experience for visitors to your website. Naturally, the final display will be contingent on your stylesheets and surrounding markup. Using the preceding `instagram` with `hidecaption` example above, the following simulates the displayed experience for visitors to your website. Naturally, the final display will be contingent on your style sheets and surrounding markup.
{{< instagram BWNjjyYFxVx hidecaption >}} {{< instagram BWNjjyYFxVx hidecaption >}}
{{% note %}} {{% note %}}
The `instagram`-shortcode refers an endpoint of Instagram's API, that's deprecated since October 24th, 2020. Thus, no images can be fetched from this API endpoint, resulting in an error when the `instagram`-shortcode is used. For more information please have a look at GitHub issue [#7879](https://github.com/gohugoio/hugo/issues/7879). The `instagram`-shortcode refers an endpoint of Instagram's API, that's deprecated since October 24th, 2020. Thus, no images can be fetched from this API endpoint, resulting in an error when the `instagram`-shortcode is used. For more information please have a look at GitHub issue [#7879](https://github.com/gohugoio/hugo/issues/7879).
{{% /note %}} {{% /note %}}
### `param` ### `param`
Gets a value from the current `Page's` params set in front matter, with a fall back to the site param value. It will log an `ERROR` if the param with the given key could not be found in either. Gets a value from the current `Page's` params set in front matter, with a fallback to the site param value. It will log an `ERROR` if the param with the given key could not be found in either.
```bash ```bash
{{</* param testparam */>}} {{</* param testparam */>}}
@ -291,7 +283,7 @@ Read a more extensive description of `ref` and `relref` in the [cross references
#### Example `ref` and `relref` Input #### Example `ref` and `relref` Input
``` ```go-html-template
[Neat]({{</* ref "blog/neat.md" */>}}) [Neat]({{</* ref "blog/neat.md" */>}})
[Who]({{</* relref "about.md#who" */>}}) [Who]({{</* relref "about.md#who" */>}})
``` ```
@ -300,7 +292,7 @@ Read a more extensive description of `ref` and `relref` in the [cross references
Assuming that standard Hugo pretty URLs are turned on. Assuming that standard Hugo pretty URLs are turned on.
``` ```html
<a href="https://example.com/blog/neat">Neat</a> <a href="https://example.com/blog/neat">Neat</a>
<a href="/about/#who">Who</a> <a href="/about/#who">Who</a>
``` ```
@ -309,13 +301,13 @@ Assuming that standard Hugo pretty URLs are turned on.
You want to include a single tweet into your blog post? Everything you need is the URL of the tweet: You want to include a single tweet into your blog post? Everything you need is the URL of the tweet:
``` ```txt
https://twitter.com/SanDiegoZoo/status/1453110110599868418 https://twitter.com/SanDiegoZoo/status/1453110110599868418
``` ```
#### Example `tweet` Input #### Example `tweet` Input
Pass the tweet's user (case-insensitive) and id from the URL as parameters to the `tweet` shortcode. Pass the tweet's user (case-insensitive) and ID from the URL as parameters to the `tweet` shortcode.
{{< code file="example-tweet-input.md" >}} {{< code file="example-tweet-input.md" >}}
{{</* tweet user="SanDiegoZoo" id="1453110110599868418" */>}} {{</* tweet user="SanDiegoZoo" id="1453110110599868418" */>}}
@ -339,7 +331,7 @@ Using the preceding `tweet` example, the following simulates the displayed exper
Adding a video from [Vimeo][] is equivalent to the [YouTube Input shortcode][]. Adding a video from [Vimeo][] is equivalent to the [YouTube Input shortcode][].
``` ```txt
https://vimeo.com/channels/staffpicks/146022717 https://vimeo.com/channels/staffpicks/146022717
``` ```
@ -360,9 +352,9 @@ Using the preceding `vimeo` example, the following HTML will be added to your re
{{< /output >}} {{< /output >}}
{{% tip %}} {{% tip %}}
If you want to further customize the visual styling of the YouTube or Vimeo output, add a `class` named parameter when calling the shortcode. The new `class` will be added to the `<div>` that wraps the `<iframe>` *and* will remove the inline styles. Note that you will need to call the `id` as a named parameter as well. You can also give the vimeo video a descriptive title with `title`. If you want to further customize the visual styling of the YouTube or Vimeo output, add a `class` named parameter when calling the shortcode. The new `class` will be added to the `<div>` that wraps the `<iframe>` *and* will remove the inline styles. Note that you will need to call the `id` as a named parameter as well. You can also give the vimeo video a descriptive title with `title`.
``` ```go
{{</* vimeo id="146022717" class="my-vimeo-wrapper-class" title="My vimeo video" */>}} {{</* vimeo id="146022717" class="my-vimeo-wrapper-class" title="My vimeo video" */>}}
``` ```
{{% /tip %}} {{% /tip %}}
@ -377,11 +369,10 @@ Using the preceding `vimeo` example, the following simulates the displayed exper
The `youtube` shortcode embeds a responsive video player for [YouTube videos][]. Only the ID of the video is required, e.g.: The `youtube` shortcode embeds a responsive video player for [YouTube videos][]. Only the ID of the video is required, e.g.:
``` ```txt
https://www.youtube.com/watch?v=w7Ft2ymGmfc https://www.youtube.com/watch?v=w7Ft2ymGmfc
``` ```
#### Example `youtube` Input #### Example `youtube` Input
Copy the YouTube video ID that follows `v=` in the video's URL and pass it to the `youtube` shortcode: Copy the YouTube video ID that follows `v=` in the video's URL and pass it to the `youtube` shortcode:
@ -390,7 +381,7 @@ Copy the YouTube video ID that follows `v=` in the video's URL and pass it to th
{{</* youtube w7Ft2ymGmfc */>}} {{</* youtube w7Ft2ymGmfc */>}}
{{< /code >}} {{< /code >}}
Furthermore, you can automatically start playback of the embedded video by setting the `autoplay` parameter to `true`. Remember that you can't mix named and unnamed parameters, so you'll need to assign the yet unnamed video id to the parameter `id`: Furthermore, you can automatically start playback of the embedded video by setting the `autoplay` parameter to `true`. Remember that you can't mix named and unnamed parameters, so you'll need to assign the yet unnamed video ID to the parameter `id`:
{{< code file="example-youtube-input-with-autoplay.md" >}} {{< code file="example-youtube-input-with-autoplay.md" >}}
@ -403,7 +394,6 @@ For [accessibility reasons](https://dequeuniversity.com/tips/provide-iframe-titl
{{</* youtube id="w7Ft2ymGmfc" title="A New Hugo Site in Under Two Minutes" */>}} {{</* youtube id="w7Ft2ymGmfc" title="A New Hugo Site in Under Two Minutes" */>}}
{{< /code >}} {{< /code >}}
#### Example `youtube` Output #### Example `youtube` Output
Using the preceding `youtube` example, the following HTML will be added to your rendered website's markup: Using the preceding `youtube` example, the following HTML will be added to your rendered website's markup:
@ -414,7 +404,7 @@ Using the preceding `youtube` example, the following HTML will be added to your
#### Example `youtube` Display #### Example `youtube` Display
Using the preceding `youtube` example (without `autoplay="true"`), the following simulates the displayed experience for visitors to your website. Naturally, the final display will be contingent on your stylesheets and surrounding markup. The video is also include in the [Quick Start of the Hugo documentation][quickstart]. Using the preceding `youtube` example (without `autoplay="true"`), the following simulates the displayed experience for visitors to your website. Naturally, the final display will be contingent on your style sheets and surrounding markup. The video is also include in the [Quick Start of the Hugo documentation][quickstart].
{{< youtube w7Ft2ymGmfc >}} {{< youtube w7Ft2ymGmfc >}}

View file

@ -1,16 +1,16 @@
--- ---
title: Static Files title: Static Files
description: "Files that get served **statically** (as-is, no modification) on the site root." linkTitle: Static Files
date: 2017-11-18 description: Files that get served **statically** (as-is, no modification) on the site root.
categories: [content management] categories: [content management]
keywords: [source, directories] keywords: [source, directories]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 130 weight: 200
weight: 130 #rem
aliases: [/static-files]
toc: true toc: true
weight: 200
aliases: [/static-files]
--- ---
By default, the `static/` directory in the site project is used for By default, the `static/` directory in the site project is used for
@ -65,6 +65,5 @@ Note 2
: The example above is a [multihost setup][]. In a regular setup, all : The example above is a [multihost setup][]. In a regular setup, all
the static directories will be available to all sites. the static directories will be available to all sites.
[site config]: /getting-started/configuration/#all-configuration-settings [site config]: /getting-started/configuration/#all-configuration-settings
[multihost setup]: /content-management/multilingual/#configure-multilingual-multihost [multihost setup]: /content-management/multilingual/#configure-multilingual-multihost

View file

@ -1,20 +1,16 @@
--- ---
title: Content Summaries title: Content Summaries
linktitle: Summaries linkTitle: Summaries
description: Hugo generates summaries of your content. description: Hugo generates summaries of your content.
date: 2017-01-10
publishdate: 2017-01-10
lastmod: 2017-01-10
categories: [content management] categories: [content management]
keywords: [summaries,abstracts,read more] keywords: [summaries,abstracts,read more]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 90 weight: 160
weight: 90 #rem
draft: false
aliases: [/content/summaries/,/content-management/content-summaries/]
toc: true toc: true
weight: 160
aliases: [/content/summaries/,/content-management/content-summaries/]
--- ---
With the use of the `.Summary` [page variable][pagevariables], Hugo generates summaries of content to use as a short version in summary views. With the use of the `.Summary` [page variable][pagevariables], Hugo generates summaries of content to use as a short version in summary views.
@ -41,9 +37,9 @@ The Hugo-defined summaries are set to use word count calculated by splitting the
### Manual Summary Splitting ### Manual Summary Splitting
Alternatively, you may add the <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> summary divider where you want to split the article. Alternatively, you may add the <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> summary divider where you want to split the article.
For [Org mode content][org], use `# more` where you want to split the article. For [Org mode content][org], use `# more` where you want to split the article.
Content that comes before the summary divider will be used as that content's summary and stored in the `.Summary` page variable with all HTML formatting intact. Content that comes before the summary divider will be used as that content's summary and stored in the `.Summary` page variable with all HTML formatting intact.

View file

@ -1,22 +1,19 @@
--- ---
title: Syntax Highlighting title: Syntax Highlighting
linkTitle: Syntax Highlighting
description: Hugo comes with really fast syntax highlighting from Chroma. description: Hugo comes with really fast syntax highlighting from Chroma.
date: 2017-02-01
publishdate: 2017-02-01
keywords: [highlighting,chroma,code blocks,syntax] keywords: [highlighting,chroma,code blocks,syntax]
categories: [content management] categories: [content management]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 300 weight: 240
weight: 20
sections_weight: 20
draft: false
aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/]
toc: true toc: true
weight: 240
aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/]
--- ---
Hugo uses [Chroma](https://github.com/alecthomas/chroma) as its code highlighter; it is built in Go and is really, really fast -- and for the most important parts compatible with Pygments we used before. Hugo uses [Chroma](https://github.com/alecthomas/chroma) as its code highlighter; it is built in Go and is really, really fast.
## Configure Syntax Highlighter ## Configure Syntax Highlighter
@ -36,11 +33,11 @@ Run `hugo gen chromastyles -h` for more options. See https://xyproto.github.io/s
## Highlight Shortcode ## Highlight Shortcode
Highlighting is carried out via the built-in [`highlight` shortcode](https://gohugo.io/content-management/shortcodes/#highlight). It takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode. Note that `highlight` is *not* used for client-side javascript highlighting. Highlighting is carried out via the built-in [`highlight` shortcode](https://gohugo.io/content-management/shortcodes/#highlight). It takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode.
Options: Options:
* `linenos`: configure line numbers. Valid values are `true`, `false`, `table`, or `inline`. `false` will turn off line numbers if it's configured to be on in site config. {{< new-in "0.60.0" >}} `table` will give copy-and-paste friendly code blocks. * `linenos`: configure line numbers. Valid values are `true`, `false`, `table`, or `inline`. `false` will turn off line numbers if it's configured to be on in site config. `table` will give copy-and-paste friendly code blocks.
* `hl_lines`: lists a set of line numbers or line number ranges to be highlighted. * `hl_lines`: lists a set of line numbers or line number ranges to be highlighted.
* `linenostart=199`: starts the line number count from 199. * `linenostart=199`: starts the line number count from 199.
* `anchorlinenos`: Configure anchors on line numbers. Valid values are `true` or `false`; * `anchorlinenos`: Configure anchors on line numbers. Valid values are `true` or `false`;
@ -49,7 +46,7 @@ Options:
### Example: Highlight Shortcode ### Example: Highlight Shortcode
``` ```go-html-template
{{</* highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" */>}} {{</* highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" */>}}
// ... code // ... code
{{</* / highlight */>}} {{</* / highlight */>}}
@ -100,9 +97,9 @@ See [Highlight](/functions/highlight/).
## Highlighting in Code Fences ## Highlighting in Code Fences
Highlighting in code fences is enabled by default.{{< new-in "0.60.0" >}} Highlighting in code fences is enabled by default.
```` ````txt
```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199} ```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199}
// ... code // ... code
``` ```
@ -134,8 +131,6 @@ func GetTitleFunc(style string) func(s string) string {
} }
``` ```
{{< new-in "0.60.0" >}}Note that only Goldmark supports passing attributes such as `hl_lines`, and it's important that it does not contain any spaces. See [goldmark-highlighting](https://github.com/yuin/goldmark-highlighting) for more information.
The options are the same as in the [highlighting shortcode](/content-management/syntax-highlighting/#highlight-shortcode),including `linenos=false`, but note the slightly different Markdown attribute syntax. The options are the same as in the [highlighting shortcode](/content-management/syntax-highlighting/#highlight-shortcode),including `linenos=false`, but note the slightly different Markdown attribute syntax.
## List of Chroma Highlighting Languages ## List of Chroma Highlighting Languages
@ -143,11 +138,3 @@ The options are the same as in the [highlighting shortcode](/content-management/
The full list of Chroma lexers and their aliases (which is the identifier used in the `highlight` template func or when doing highlighting in code fences): The full list of Chroma lexers and their aliases (which is the identifier used in the `highlight` template func or when doing highlighting in code fences):
{{< chroma-lexers >}} {{< chroma-lexers >}}
[Prism]: https://prismjs.com
[prismdownload]: https://prismjs.com/download.html
[Highlight.js]: https://highlightjs.org/
[Rainbow]: https://craig.is/making/rainbows
[Syntax Highlighter]: https://alexgorbatchev.com/SyntaxHighlighter/
[Google Prettify]: https://github.com/google/code-prettify
[Yandex]: https://yandex.ru/

View file

@ -1,19 +1,16 @@
--- ---
title: Taxonomies title: Taxonomies
linktitle: linkTitle: Taxonomies
description: Hugo includes support for user-defined taxonomies. description: Hugo includes support for user-defined taxonomies.
date: 2017-02-01
publishdate: 2017-02-01
keywords: [taxonomies,metadata,front matter,terms] keywords: [taxonomies,metadata,front matter,terms]
categories: [content management] categories: [content management]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 80 weight: 150
weight: 80 #rem
draft: false
aliases: [/taxonomies/overview/,/taxonomies/usage/,/indexes/overview/,/doc/indexes/,/extras/indexes]
toc: true toc: true
weight: 150
aliases: [/taxonomies/overview/,/taxonomies/usage/,/indexes/overview/,/doc/indexes/,/extras/indexes]
--- ---
## What is a Taxonomy? ## What is a Taxonomy?
@ -49,7 +46,7 @@ Then, in each of the movies, you would specify terms for each of these taxonomie
To continue with the example of a movie site, the following demonstrates content relationships from the perspective of the taxonomy: To continue with the example of a movie site, the following demonstrates content relationships from the perspective of the taxonomy:
``` ```txt
Actor <- Taxonomy Actor <- Taxonomy
Bruce Willis <- Term Bruce Willis <- Term
The Sixth Sense <- Value The Sixth Sense <- Value
@ -63,7 +60,7 @@ Actor <- Taxonomy
From the perspective of the content, the relationships would appear differently, although the data and labels used are the same: From the perspective of the content, the relationships would appear differently, although the data and labels used are the same:
``` ```txt
Unbreakable <- Value Unbreakable <- Value
Actors <- Taxonomy Actors <- Taxonomy
Bruce Willis <- Term Bruce Willis <- Term
@ -98,8 +95,6 @@ If you do not want Hugo to create any taxonomies, set `disableKinds` in your [si
disableKinds = ["taxonomy","term"] disableKinds = ["taxonomy","term"]
{{</ code-toggle >}} {{</ code-toggle >}}
{{< new-in "0.73.0" >}} We have fixed the before confusing page kinds used for taxonomies (see the listing below) to be in line with the terms used when we talk about taxonomies. We have been careful to avoid site breakage, and you should get an ERROR in the console if you need to adjust your `disableKinds` section.
{{% page-kinds %}} {{% page-kinds %}}
### Default Destinations ### Default Destinations
@ -111,7 +106,7 @@ When taxonomies are used---and [taxonomy templates][] are provided---Hugo will a
## Configure Taxonomies ## Configure Taxonomies
Custom taxonomies other than the [defaults](#default-taxonomies) must be defined in your [site config][config] before they can be used throughout the site. You need to provide both the plural and singular labels for each taxonomy. For example, `singular key = "plural value"` for TOML and `singular key: "plural value"` for YAML. Custom taxonomies other than the [defaults]({{< relref "taxonomies.md#default-taxonomies" >}}) must be defined in your [site config][config] before they can be used throughout the site. You need to provide both the plural and singular labels for each taxonomy. For example, `singular key = "plural value"` for TOML and `singular key: "plural value"` for YAML.
### Example: Adding a custom taxonomy named "series" ### Example: Adding a custom taxonomy named "series"
@ -135,7 +130,7 @@ If you want to have just the default `tags` taxonomy, and remove the `categories
tag = "tags" tag = "tags"
{{</ code-toggle >}} {{</ code-toggle >}}
If you want to disable all taxonomies altogether, see the use of `disableKinds` in [Hugo Taxonomy Defaults](#default-taxonomies). If you want to disable all taxonomies altogether, see the use of `disableKinds` in [Hugo Taxonomy Defaults]({{< relref "taxonomies.md#default-taxonomies" >}}).
{{% note %}} {{% note %}}
You can add content and front matter to your taxonomy list and taxonomy terms pages. See [Content Organization](/content-management/organization/) for more information on how to add an `_index.md` for this purpose. You can add content and front matter to your taxonomy list and taxonomy terms pages. See [Content Organization](/content-management/organization/) for more information on how to add an `_index.md` for this purpose.
@ -174,7 +169,7 @@ project_url = "https://github.com/gohugoio/hugo"
A content file can assign weight for each of its associate taxonomies. Taxonomic weight can be used for sorting or ordering content in [taxonomy list templates][] and is declared in a content file's [front matter][]. The convention for declaring taxonomic weight is `taxonomyname_weight`. A content file can assign weight for each of its associate taxonomies. Taxonomic weight can be used for sorting or ordering content in [taxonomy list templates][] and is declared in a content file's [front matter][]. The convention for declaring taxonomic weight is `taxonomyname_weight`.
The following TOML and YAML examples show a piece of content that has a weight of 22, which can be used for ordering purposes when rendering the pages assigned to the "a", "b" and "c" values of the `tags` taxonomy. It has also been assigned the weight of 44 when rendering the "d" category page. The following show a piece of content that has a weight of 22, which can be used for ordering purposes when rendering the pages assigned to the "a", "b" and "c" values of the `tags` taxonomy. It has also been assigned the weight of 44 when rendering the "d" category page.
### Example: Taxonomic `weight` ### Example: Taxonomic `weight`
@ -194,7 +189,7 @@ Currently taxonomies only support the [default `weight => date` ordering of list
## Add custom metadata to a Taxonomy or Term ## Add custom metadata to a Taxonomy or Term
If you need to add custom metadata to your taxonomy terms, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in it's front matter. Continuing with our 'Actors' example, let's say you want to add a Wikipedia page link to each actor. Your terms pages would be something like this: If you need to add custom metadata to your taxonomy terms, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in its front matter. Continuing with our 'Actors' example, let's say you want to add a Wikipedia page link to each actor. Your terms pages would be something like this:
{{< code file="/content/actors/bruce-willis/_index.md" >}} {{< code file="/content/actors/bruce-willis/_index.md" >}}
--- ---

View file

@ -1,20 +1,16 @@
--- ---
title: Table of Contents title: Table of Contents
linktitle: linkTitle: Table of Contents
description: Hugo can automatically parse Markdown content and create a Table of Contents you can use in your templates. description: Hugo can automatically parse Markdown content and create a Table of Contents you can use in your templates.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [content management] categories: [content management]
keywords: [table of contents, toc] keywords: [table of contents, toc]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 130 weight: 210
weight: 130 #rem
draft: false
aliases: [/extras/toc/]
toc: true toc: true
weight: 210
aliases: [/extras/toc/]
--- ---
{{% note "TOC Heading Levels are Fixed" %}} {{% note "TOC Heading Levels are Fixed" %}}
@ -27,9 +23,9 @@ Hugo [v0.60.0](https://github.com/gohugoio/hugo/releases/tag/v0.60.0) made a swi
## Usage ## Usage
Create your markdown the way you normally would with the appropriate headings. Here is some example content: Create your Markdown the way you normally would with the appropriate headings. Here is some example content:
``` ```md
<!-- Your front matter up here --> <!-- Your front matter up here -->
## Introduction ## Introduction

View file

@ -1,24 +1,21 @@
--- ---
title: Content Types title: Content Types
linkTitle: Content Types
description: Hugo is built around content organized in sections. description: Hugo is built around content organized in sections.
date: 2017-02-01
categories: [content management] categories: [content management]
keywords: [lists,sections,content types,types,organization] keywords: [lists, sections, content types, types, organization]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 60 weight: 130
weight: 60 #rem
draft: false
aliases: [/content/types]
toc: true toc: true
weight: 130
aliases: [/content/types]
--- ---
A **content type** is a way to organize your content. Hugo resolves the content type from either the `type` in front matter or, if not set, the first directory in the file path. E.g. `content/blog/my-first-event.md` will be of type `blog` if no `type` is set. A **content type** is a way to organize your content. Hugo resolves the content type from either the `type` in front matter or, if not set, the first directory in the file path. E.g. `content/blog/my-first-event.md` will be of type `blog` if no `type` is set.
A content type is used to A content type is used to
* Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](https://gohugo.io/templates/views) for more. - Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](https://gohugo.io/templates/views) for more.
* Determine which [archetype](/content-management/archetypes/) template to use for new content. - Determine which [archetype](/content-management/archetypes/) template to use for new content.

View file

@ -1,20 +1,16 @@
--- ---
title: URL Management title: URL Management
linktitle: URL Management linkTitle: URL Management
description: Hugo supports permalinks, aliases, link canonicalization, and multiple options for handling relative vs absolute URLs. description: Hugo supports permalinks, aliases, link canonicalization, and multiple options for handling relative vs absolute URLs.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-03-09
keywords: [aliases,redirects,permalinks,urls]
categories: [content management] categories: [content management]
keywords: [aliases,redirects,permalinks,urls]
menu: menu:
docs: docs:
parent: "content-management" parent: content-management
weight: 110 weight: 180
weight: 110 #rem
draft: false
aliases: [/extras/permalinks/,/extras/aliases/,/extras/urls/,/doc/redirects/,/doc/alias/,/doc/aliases/]
toc: true toc: true
weight: 180
aliases: [/extras/permalinks/,/extras/aliases/,/extras/urls/,/doc/redirects/,/doc/alias/,/doc/aliases/]
--- ---
## Permalinks ## Permalinks
@ -45,7 +41,7 @@ permalinks:
/: /:year/:month/:filename/ /: /:year/:month/:filename/
{{< /code-toggle >}} {{< /code-toggle >}}
If the standard date-based permalink configuration does not meet your needs, you can also format URL segments using [Go time formatting directives](https://golang.org/pkg/time/#Time.Format). For example, a URL structure with two digit years and month and day digits without zero padding can be accomplished with: If the standard date-based permalink configuration does not meet your needs, you can also format URL segments using [Go time formatting directives](https://pkg.go.dev/time#Time.Format). For example, a URL structure with two digit years and month and day digits without zero padding can be accomplished with:
{{< code-toggle file="config" copy="false" >}} {{< code-toggle file="config" copy="false" >}}
permalinks: permalinks:
@ -83,7 +79,7 @@ The following is a list of values that can be used in a `permalink` definition i
: the content's section : the content's section
`:sections` `:sections`
: the content's sections hierarchy. {{< new-in "0.83.0" >}} Since Hugo 0.83 you can use a selection of the sections using _slice syntax_: `:sections[1:]` includes all but the first, `:sections[:last]` includes all but the last, `:sections[last]` includes only the last, `:sections[1:2]` includes section 2 and 3. Note that this slice access will not throw any out-of-bounds errors, so you don't have to be exact. : the content's sections hierarchy. Uou can use a selection of the sections using _slice syntax_: `:sections[1:]` includes all but the first, `:sections[:last]` includes all but the last, `:sections[last]` includes only the last, `:sections[1:2]` includes section 2 and 3. Note that this slice access will not throw any out-of-bounds errors, so you don't have to be exact.
`:title` `:title`
: the content's title : the content's title
@ -133,7 +129,7 @@ aliases:
--- ---
{{< /code >}} {{< /code >}}
Now when you visit any of the locations specified in aliases---i.e., *assuming the same site domain*---you'll be redirected to the page they are specified on. For example, a visitor to `example.com/posts/my-original-url/` will be immediately redirected to `example.com/posts/my-awesome-post/`. Now when you visit any of the locations specified in aliases---i.e., _assuming the same site domain_---you'll be redirected to the page they are specified on. For example, a visitor to `example.com/posts/my-original-url/` will be immediately redirected to `example.com/posts/my-awesome-post/`.
### Example: Aliases in Multilingual ### Example: Aliases in Multilingual
@ -141,14 +137,14 @@ On [multilingual sites][multilingual], each translation of a post can have uniqu
In `/posts/my-new-post.es.md`: In `/posts/my-new-post.es.md`:
``` ```md
--- ---
aliases: aliases:
- /es/posts/my-original-post/ - /es/posts/my-original-post/
--- ---
``` ```
From Hugo 0.55 you can also have page-relative aliases, so ` /es/posts/my-original-post/` can be simplified to the more portable `my-original-post/` From Hugo 0.55 you can also have page-relative aliases, so `/es/posts/my-original-post/` can be simplified to the more portable `my-original-post/`
### How Hugo Aliases Work ### How Hugo Aliases Work
@ -156,7 +152,7 @@ When aliases are specified, Hugo creates a directory to match the alias entry. I
For example, a content file at `posts/my-intended-url.md` with the following in the front matter: For example, a content file at `posts/my-intended-url.md` with the following in the front matter:
``` ```yml
--- ---
title: My New post title: My New post
aliases: [/posts/my-old-url/] aliases: [/posts/my-old-url/]
@ -165,7 +161,7 @@ aliases: [/posts/my-old-url/]
Assuming a `baseURL` of `example.com`, the contents of the auto-generated alias `.html` found at `https://example.com/posts/my-old-url/` will contain the following: Assuming a `baseURL` of `example.com`, the contents of the auto-generated alias `.html` found at `https://example.com/posts/my-old-url/` will contain the following:
``` ```html
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -204,7 +200,7 @@ Hugo's default behavior is to render your content with "pretty" URLs. No non-sta
The following demonstrates the concept: The following demonstrates the concept:
``` ```txt
content/posts/_index.md content/posts/_index.md
=> example.com/posts/ => example.com/posts/
content/posts/post-1.md content/posts/post-1.md
@ -219,7 +215,7 @@ If you want a specific piece of content to have an exact URL, you can specify th
See [Content Organization][contentorg] for more details on paths. See [Content Organization][contentorg] for more details on paths.
``` ```txt
. .
└── content └── content
└── about └── about
@ -236,7 +232,7 @@ See [Content Organization][contentorg] for more details on paths.
Here's the same organization run with `hugo --uglyURLs`: Here's the same organization run with `hugo --uglyURLs`:
``` ```txt
. .
└── content └── content
└── about └── about
@ -251,7 +247,6 @@ Here's the same organization run with `hugo --uglyURLs`:
└── second.md // <- https://example.com/quote/second.html └── second.md // <- https://example.com/quote/second.html
``` ```
## Canonicalization ## Canonicalization
By default, all relative URLs encountered in the input are left unmodified, e.g. `/css/foo.css` would stay as `/css/foo.css`. The `canonifyURLs` field in your site `config` has a default value of `false`. By default, all relative URLs encountered in the input are left unmodified, e.g. `/css/foo.css` would stay as `/css/foo.css`. The `canonifyURLs` field in your site `config` has a default value of `false`.
@ -268,13 +263,13 @@ In the May 2014 release of Hugo v0.11, the default value of `canonifyURLs` was s
To find out the current value of `canonifyURLs` for your website, you may use the handy `hugo config` command added in v0.13. To find out the current value of `canonifyURLs` for your website, you may use the handy `hugo config` command added in v0.13.
``` ```txt
hugo config | grep -i canon hugo config | grep -i canon
``` ```
Or, if you are on Windows and do not have `grep` installed: Or, if you are on Windows and do not have `grep` installed:
``` ```txt
hugo config | FINDSTR /I canon hugo config | FINDSTR /I canon
``` ```
@ -300,7 +295,6 @@ url: "custom/foo"
--- ---
``` ```
## Relative URLs ## Relative URLs
By default, all relative URLs are left unchanged by Hugo, which can be problematic when you want to make your site browsable from a local file system. By default, all relative URLs are left unchanged by Hugo, which can be problematic when you want to make your site browsable from a local file system.

View file

@ -4,7 +4,6 @@ linktitle: Development
description: Hugo relies heavily on contributions from the open source community. description: Hugo relies heavily on contributions from the open source community.
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [contribute] categories: [contribute]
keywords: [dev,open source] keywords: [dev,open source]
authors: [digitalcraftsman] authors: [digitalcraftsman]
@ -14,7 +13,6 @@ menu:
weight: 10 weight: 10
weight: 10 weight: 10
sections_weight: 10 sections_weight: 10
draft: false
toc: true toc: true
--- ---
@ -45,13 +43,13 @@ If you are having trouble following the installation guides for Go, check out [G
Once you're finished installing Go, let's confirm everything is working correctly. Open a terminal---or command line under Windows--and type the following: Once you're finished installing Go, let's confirm everything is working correctly. Open a terminal---or command line under Windows--and type the following:
``` ```txt
go version go version
``` ```
You should see something similar to the following written to the console. Note that the version here reflects the most recent version of Go as of the last update for this page: You should see something similar to the following written to the console. Note that the version here reflects the most recent version of Go as of the last update for this page:
``` ```txt
go version go1.12 darwin/amd64 go version go1.12 darwin/amd64
``` ```
@ -59,13 +57,13 @@ Next, make sure that you set up your `GOPATH` [as described in the installation
You can print the `GOPATH` with `echo $GOPATH`. You should see a non-empty string containing a valid path to your Go workspace; for example: You can print the `GOPATH` with `echo $GOPATH`. You should see a non-empty string containing a valid path to your Go workspace; for example:
``` ```txt
/Users/<yourusername>/Code/go /Users/<yourusername>/Code/go
``` ```
### Install Go with Homebrew ### Install Go with Homebrew
If you are a MacOS user and have [Homebrew](https://brew.sh/) installed on your machine, installing Go is as simple as the following command: If you are a macOS user and have [Homebrew](https://brew.sh/) installed on your machine, installing Go is as simple as the following command:
{{< code file="install-go.sh" >}} {{< code file="install-go.sh" >}}
brew install go brew install go
@ -87,7 +85,7 @@ You will need to have Git installed on your computer to contribute to Hugo devel
Git is a [version control system](https://en.wikipedia.org/wiki/Version_control) to track the changes of source code. Hugo depends on smaller third-party packages that are used to extend the functionality. We use them because we don't want to reinvent the wheel. Git is a [version control system](https://en.wikipedia.org/wiki/Version_control) to track the changes of source code. Hugo depends on smaller third-party packages that are used to extend the functionality. We use them because we don't want to reinvent the wheel.
Go ships with a sub-command called `get` that will download these packages for us when we setup our working environment. The source code of the packages is tracked with Git. `get` will interact with the Git servers of the package hosters in order to fetch all dependencies. Go ships with a sub-command called `get` that will download these packages for us when we set up our working environment. The source code of the packages is tracked with Git. `get` will interact with the Git servers of the package hosters in order to fetch all dependencies.
Move back to the terminal and check if Git is already installed. Type in `git version` and press enter. You can skip the rest of this section if the command returned a version number. Otherwise [download](https://git-scm.com/downloads) the latest version of Git and follow this [installation guide](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). Move back to the terminal and check if Git is already installed. Type in `git version` and press enter. You can skip the rest of this section if the command returned a version number. Otherwise [download](https://git-scm.com/downloads) the latest version of Git and follow this [installation guide](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
@ -95,7 +93,7 @@ Finally, check again with `git version` if Git was installed successfully.
### Git Graphical Front Ends ### Git Graphical Front Ends
There are several [GUI clients](https://git-scm.com/downloads/guis) that help you to operate Git. Not all are available for all operating systems and maybe differ in their usage. Because of this we will document how to use the command line, since the commands are the same everywhere. There are several [GUI clients](https://git-scm.com/downloads/guis) that help you to operate Git. Not all are available for all operating systems and maybe differ in their usage. Because of this we will document how to use the command-line, since the commands are the same everywhere.
### Install Hub on Your System (Optional) ### Install Hub on Your System (Optional)
@ -103,19 +101,19 @@ Hub is a great tool for working with GitHub. The main site for it is [hub.github
On a Mac, you can install [Hub](https://github.com/github/hub) using [Homebrew](https://brew.sh): On a Mac, you can install [Hub](https://github.com/github/hub) using [Homebrew](https://brew.sh):
``` ```txt
brew install hub brew install hub
``` ```
Now we'll create an [alias in Bash](https://tldp.org/LDP/abs/html/aliases.html) so that typing `git` actually runs `Hub`: Now we'll create an [alias in Bash](https://tldp.org/LDP/abs/html/aliases.html) so that typing `git` actually runs `Hub`:
``` ```txt
echo "alias git='hub'" >> ~/.bash_profile echo "alias git='hub'" >> ~/.bash_profile
``` ```
Confirm the installation: Confirm the installation:
``` ```txt
git version 2.21.0 git version 2.21.0
hub version 2.10.0 hub version 2.10.0
``` ```
@ -134,26 +132,25 @@ We're going to clone the [master Hugo repository](https://github.com/gohugoio/hu
So, let's make a new directory and clone that master repository: So, let's make a new directory and clone that master repository:
``` ```txt
mkdir $HOME/src mkdir $HOME/src
cd $HOME/src cd $HOME/src
git clone https://github.com/gohugoio/hugo.git git clone https://github.com/gohugoio/hugo.git
``` ```
> Since Hugo 0.48, Hugo uses the Go Modules support built into Go 1.11 to build. > Since Hugo 0.48, Hugo uses the Go Modules support built into Go 1.11 to build.
> The easiest is to clone Hugo in a directory outside of GOPATH > The easiest is to clone Hugo in a directory outside of GOPATH
And then, install dependencies of Hugo by running the following in the cloned directory: And then, install dependencies of Hugo by running the following in the cloned directory:
``` ```txt
cd $HOME/src/hugo cd $HOME/src/hugo
go install go install
``` ```
Hugo relies on [mage](https://github.com/magefile/mage) for some convenient build and test targets. If you don't already have it, get it: Hugo relies on [mage](https://github.com/magefile/mage) for some convenient build and test targets. If you don't already have it, get it:
``` ```txt
go install github.com/magefile/mage@latest go install github.com/magefile/mage@latest
``` ```
@ -169,19 +166,19 @@ Open the [Hugo repository](https://github.com/gohugoio/hugo) on GitHub and click
![Fork button](/images/contribute/development/forking-a-repository.png) ![Fork button](/images/contribute/development/forking-a-repository.png)
Now open your fork repository on GitHub and copy the remote url of your fork. You can choose between HTTPS and SSH as protocol that Git should use for the following operations. HTTPS works always [if you're not sure](https://help.github.com/articles/which-remote-url-should-i-use/). Now open your fork repository on GitHub and copy the remote URL of your fork. You can choose between HTTPS and SSH as protocol that Git should use for the following operations. HTTPS works always [if you're not sure](https://help.github.com/articles/which-remote-url-should-i-use/).
![Copy remote url](/images/contribute/development/copy-remote-url.png) ![Copy remote url](/images/contribute/development/copy-remote-url.png)
Switch back to the terminal and move into the directory of the cloned master repository from the last step. Switch back to the terminal and move into the directory of the cloned master repository from the last step.
``` ```txt
cd $HOME/src/hugo cd $HOME/src/hugo
``` ```
Now Git needs to know that our fork exists by adding the copied remote url: Now Git needs to know that our fork exists by adding the copied remote url:
``` ```txt
git remote add <YOUR-GITHUB-USERNAME> <COPIED REMOTE-URL> git remote add <YOUR-GITHUB-USERNAME> <COPIED REMOTE-URL>
``` ```
@ -189,7 +186,7 @@ git remote add <YOUR-GITHUB-USERNAME> <COPIED REMOTE-URL>
Alternatively, you can use the Git wrapper Hub. Hub makes forking a repository easy: Alternatively, you can use the Git wrapper Hub. Hub makes forking a repository easy:
``` ```txt
git fork git fork
``` ```
@ -199,13 +196,13 @@ That command will log in to GitHub using your account, create a fork of the repo
Let's check if everything went right by listing all known remotes: Let's check if everything went right by listing all known remotes:
``` ```txt
git remote -v git remote -v
``` ```
The output should look similar: The output should look similar:
``` ```txt
digitalcraftsman git@github.com:digitalcraftsman/hugo.git (fetch) digitalcraftsman git@github.com:digitalcraftsman/hugo.git (fetch)
digitalcraftsman git@github.com:digitalcraftsman/hugo.git (push) digitalcraftsman git@github.com:digitalcraftsman/hugo.git (push)
origin https://github.com/gohugoio/hugo (fetch) origin https://github.com/gohugoio/hugo (fetch)
@ -220,14 +217,14 @@ You should never develop against the "master" branch. The development team will
First, you should always pull the latest changes from the master repository: First, you should always pull the latest changes from the master repository:
``` ```txt
git checkout master git checkout master
git pull git pull
``` ```
Now we can create a new branch for your additions: Now we can create a new branch for your additions:
``` ```txt
git checkout -b <BRANCH-NAME> git checkout -b <BRANCH-NAME>
``` ```
@ -245,7 +242,7 @@ We have developed a [separate Hugo documentation contribution guide][docscontrib
While making changes in the codebase it's a good idea to build the binary to test them: While making changes in the codebase it's a good idea to build the binary to test them:
``` ```txt
mage hugo mage hugo
``` ```
@ -253,31 +250,33 @@ This command generates the binary file at the root of the repository.
If you want to install the binary in `$GOPATH/bin`, run If you want to install the binary in `$GOPATH/bin`, run
``` ```txt
mage install mage install
``` ```
### Test ### Test
Sometimes changes on the codebase can cause unintended side effects. Or they don't work as expected. Most functions have their own test cases. You can find them in files ending with `_test.go`. Sometimes changes on the codebase can cause unintended side effects. Or they don't work as expected. Most functions have their own test cases. You can find them in files ending with `_test.go`.
Make sure the commands Make sure the commands
``` ```txt
mage -v check mage -v check
``` ```
passes. passes.
### Formatting ### Formatting
The Go code styleguide maybe is opinionated but it ensures that the codebase looks the same, regardless who wrote the code. Go comes with its own formatting tool. Let's apply the styleguide to our additions:
``` The Go code style guide maybe is opinionated but it ensures that the codebase looks the same, regardless who wrote the code. Go comes with its own formatting tool. Let's apply the style guide to our additions:
```txt
mage fmt mage fmt
``` ```
Once you made your additions commit your changes. Make sure that you follow our [code contribution guidelines](https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md): Once you made your additions commit your changes. Make sure that you follow our [code contribution guidelines](https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md):
``` ```txt
# Add all changed files # Add all changed files
git add --all git add --all
git commit --message "YOUR COMMIT MESSAGE" git commit --message "YOUR COMMIT MESSAGE"
@ -295,20 +294,20 @@ If you are unsure what a command does leave the commit as it is. We can fix your
Let's say you want to modify the last commit message. Run the following command and replace the current message: Let's say you want to modify the last commit message. Run the following command and replace the current message:
``` ```txt
git commit --amend -m"YOUR NEW COMMIT MESSAGE" git commit --amend -m"YOUR NEW COMMIT MESSAGE"
``` ```
Take a look at the commit log to see the change: Take a look at the commit log to see the change:
``` ```txt
git log git log
# Exit with q # Exit with q
``` ```
After making the last commit you may have forgot something. There is no need to create a new commit. Just add the latest changes and merge them into the intended commit: After making the last commit you may have forgotten something. There is no need to create a new commit. Just add the latest changes and merge them into the intended commit:
``` ```txt
git add --all git add --all
git commit --amend git commit --amend
``` ```
@ -321,13 +320,13 @@ Modifications such as those described in this section can have serious unintende
This is a bit more advanced. Git allows you to [rebase](https://git-scm.com/docs/git-rebase) commits interactively. In other words: it allows you to rewrite the commit history. This is a bit more advanced. Git allows you to [rebase](https://git-scm.com/docs/git-rebase) commits interactively. In other words: it allows you to rewrite the commit history.
``` ```txt
git rebase --interactive @~6 git rebase --interactive @~6
``` ```
The `6` at the end of the command represents the number of commits that should be modified. An editor should open and present a list of last six commit messages: The `6` at the end of the command represents the number of commits that should be modified. An editor should open and present a list of last six commit messages:
``` ```txt
pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test" pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test"
pick aaee038 tpl: Sort the smoke tests pick aaee038 tpl: Sort the smoke tests
pick f0dbf2c tpl: Add the other test case for hasPrefix pick f0dbf2c tpl: Add the other test case for hasPrefix
@ -340,7 +339,7 @@ In the case above we should merge the last two commits in the commit of this tut
All operations are written before the commit message. Replace "pick" with an operation. In this case `squash` or `s` for short: All operations are written before the commit message. Replace "pick" with an operation. In this case `squash` or `s` for short:
``` ```txt
pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test" pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test"
pick aaee038 tpl: Sort the smoke tests pick aaee038 tpl: Sort the smoke tests
pick f0dbf2c tpl: Add the other test case for hasPrefix pick f0dbf2c tpl: Add the other test case for hasPrefix
@ -353,7 +352,7 @@ We also want to rewrite the commits message of the third last commit. We forgot
You should end up with a similar setup: You should end up with a similar setup:
``` ```txt
pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test" pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test"
pick aaee038 tpl: Sort the smoke tests pick aaee038 tpl: Sort the smoke tests
pick f0dbf2c tpl: Add the other test case for hasPrefix pick f0dbf2c tpl: Add the other test case for hasPrefix
@ -366,7 +365,7 @@ Close the editor. It should open again with a new tab. A text is instructing you
A last time a new tab opens. Enter a new commit message and save again. Your terminal should contain a status message. Hopefully this one: A last time a new tab opens. Enter a new commit message and save again. Your terminal should contain a status message. Hopefully this one:
``` ```txt
Successfully rebased and updated refs/heads/<BRANCHNAME>. Successfully rebased and updated refs/heads/<BRANCHNAME>.
``` ```
@ -374,9 +373,9 @@ Check the commit log if everything looks as expected. Should an error occur you
### Push commits ### Push commits
To push our commits to the fork on GitHub we need to specify a destination. A destination is defined by the remote and a branch name. Earlier, the defined that the remote url of our fork is the same as our GitHub handle, in my case `digitalcraftsman`. The branch should have the same as our local one. This makes it easy to identify corresponding branches. To push our commits to the fork on GitHub we need to specify a destination. A destination is defined by the remote and a branch name. Earlier, the defined that the remote URL of our fork is the same as our GitHub handle, in my case `digitalcraftsman`. The branch should have the same as our local one. This makes it easy to identify corresponding branches.
``` ```txt
git push --set-upstream <YOUR-GITHUB-USERNAME> <BRANCHNAME> git push --set-upstream <YOUR-GITHUB-USERNAME> <BRANCHNAME>
``` ```
@ -402,7 +401,7 @@ Last but not least you should accept the contributor license agreement (CLA). A
### Automatic builds ### Automatic builds
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. We use a GitHub Actions workflow to build and test. This is a matrix build across combinations of operating system (macOS, 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.
## Where to start? ## Where to start?
@ -417,18 +416,17 @@ Feel free to [open an issue][newissue] if you think you found a bug or you have
* [The Git Book][gitbook] (Free) * [The Git Book][gitbook] (Free)
* [Go Bootcamp][gobootcamp] * [Go Bootcamp][gobootcamp]
[codecademy]: https://www.codecademy.com/learn/learn-git [codecademy]: https://www.codecademy.com/learn/learn-git
[contributors]: https://github.com/gohugoio/hugo/graphs/contributors [contributors]: https://github.com/gohugoio/hugo/graphs/contributors
[docscontrib]: /contribute/documentation/ [docscontrib]: /contribute/documentation/
[forums]: https://discourse.gohugo.io [forums]: https://discourse.gohugo.io
[gitbook]: https://git-scm.com/ [gitbook]: https://git-scm.com/
[gobootcamp]: https://www.golangbootcamp.com/book/get_setup [gobootcamp]: https://www.golangbootcamp.com/book/get_setup
[godl]: https://golang.org/dl/ [godl]: https://go.dev/dl/
[goinstall]: https://golang.org/doc/install [goinstall]: https://go.dev/doc/install
[gvm]: https://github.com/moovweb/gvm [gvm]: https://github.com/moovweb/gvm
[issues]: https://github.com/gohugoio/hugo/issues [issues]: https://github.com/gohugoio/hugo/issues
[newissue]: https://github.com/gohugoio/hugo/issues/new [newissue]: https://github.com/gohugoio/hugo/issues/new
[releases]: /getting-started/ [releases]: /getting-started/
[setupgopath]: https://golang.org/doc/code.html#Workspaces [setupgopath]: https://go.dev/doc/code#Workspaces
[trygit]: https://try.github.io/levels/1/challenges/1 [trygit]: https://try.github.io/levels/1/challenges/1

View file

@ -4,7 +4,6 @@ linktitle: Documentation
description: Documentation is an integral part of any open source project. The Hugo docs are as much a work in progress as the source it attempts to cover. description: Documentation is an integral part of any open source project. The Hugo docs are as much a work in progress as the source it attempts to cover.
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [contribute] categories: [contribute]
keywords: [docs,documentation,community, contribute] keywords: [docs,documentation,community, contribute]
menu: menu:
@ -13,7 +12,6 @@ menu:
weight: 20 weight: 20
weight: 20 weight: 20
sections_weight: 20 sections_weight: 20
draft: false
aliases: [/contribute/docs/] aliases: [/contribute/docs/]
toc: true toc: true
--- ---
@ -24,7 +22,7 @@ It's best to make changes to the Hugo docs on your local machine to check for co
You can then create a separate branch for your additions. Be sure to choose a descriptive branch name that best fits the type of content. The following is an example of a branch name you might use for adding a new website to the showcase: You can then create a separate branch for your additions. Be sure to choose a descriptive branch name that best fits the type of content. The following is an example of a branch name you might use for adding a new website to the showcase:
``` ```txt
git checkout -b jon-doe-showcase-addition git checkout -b jon-doe-showcase-addition
``` ```
@ -34,15 +32,15 @@ The Hugo docs make heavy use of Hugo's [archetypes][] feature. All content secti
Adding new content to the Hugo docs follows the same pattern, regardless of the content section: Adding new content to the Hugo docs follows the same pattern, regardless of the content section:
``` ```txt
hugo new <DOCS-SECTION>/<new-content-lowercase>.md hugo new <DOCS-SECTION>/<new-content-lowercase>.md
``` ```
### Add a New Function ### Add a New Function
Once you have cloned the Hugo repository, you can create a new function via the following command. Keep the file name lowercase. Once you have cloned the Hugo repository, you can create a new function via the following command. Keep the filename lowercase.
``` ```txt
hugo new functions/newfunction.md hugo new functions/newfunction.md
``` ```
@ -94,13 +92,13 @@ Code blocks are crucial for providing examples of Hugo's new features to end use
### Standard Syntax ### Standard Syntax
Across many pages on the Hugo docs, the typical triple-back-tick markdown syntax (```` ``` ````) is used. If you do not want to take the extra time to implement the following code block shortcodes, please use standard GitHub-flavored markdown. The Hugo docs use a version of [highlight.js](https://highlightjs.org/) with a specific set of languages. Across many pages on the Hugo docs, the typical triple-back-tick Markdown syntax (```` ``` ````) is used. If you do not want to take the extra time to implement the following code block shortcodes, please use standard GitHub-flavored Markdown.
Your options for languages are `xml`/`html`, `go`/`golang`, `md`/`markdown`/`mkd`, `handlebars`, `apache`, `toml`, `yaml`, `json`, `css`, `asciidoc`, `ruby`, `powershell`/`ps`, `scss`, `sh`/`zsh`/`bash`/`git`, `http`/`https`, and `javascript`/`js`. ````txt
```go-html-template
```` {{ range site.RegularPages }}
``` <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
<h1>Hello world!</h1> {{ end }}
``` ```
```` ````
@ -117,7 +115,7 @@ With the `code` shortcodes, *you must include triple back ticks and a language d
`code` is the Hugo docs shortcode you'll use most often. `code` requires has only one named parameter: `file`. Here is the pattern: `code` is the Hugo docs shortcode you'll use most often. `code` requires has only one named parameter: `file`. Here is the pattern:
``` ```go-html-template
{{%/* code file="smart/file/name/with/path.html" download="download.html" copy="true" */%}} {{%/* code file="smart/file/name/with/path.html" download="download.html" copy="true" */%}}
A whole bunch of coding going on up in here! A whole bunch of coding going on up in here!
{{%/* /code */%}} {{%/* /code */%}}
@ -125,7 +123,6 @@ A whole bunch of coding going on up in here!
The following are the arguments passed into `code`: The following are the arguments passed into `code`:
***`file`*** ***`file`***
: the only *required* argument. `file` is needed for styling but also plays an important role in helping users create a mental model around Hugo's directory structure. Visually, this will be displayed as text in the top left of the code block. : the only *required* argument. `file` is needed for styling but also plays an important role in helping users create a mental model around Hugo's directory structure. Visually, this will be displayed as text in the top left of the code block.
@ -142,7 +139,7 @@ This example HTML code block tells Hugo users the following:
1. This file *could* live in `layouts/_default`, as demonstrated by `layouts/_default/single.html` as the value for `file`. 1. This file *could* live in `layouts/_default`, as demonstrated by `layouts/_default/single.html` as the value for `file`.
2. This snippet is complete enough to be downloaded and implemented in a Hugo project, as demonstrated by `download="single.html"`. 2. This snippet is complete enough to be downloaded and implemented in a Hugo project, as demonstrated by `download="single.html"`.
``` ```go-html-template
{{</* code file="layouts/_default/single.html" download="single.html" */>}} {{</* code file="layouts/_default/single.html" download="single.html" */>}}
{{ define "main" }} {{ define "main" }}
<main> <main>
@ -210,7 +207,7 @@ The preceding `output` example will render as follows to the Hugo docs:
Blockquotes can be added to the Hugo documentation using [typical Markdown blockquote syntax][bqsyntax]: Blockquotes can be added to the Hugo documentation using [typical Markdown blockquote syntax][bqsyntax]:
``` ```md
> Without the threat of punishment, there is no joy in flight. > Without the threat of punishment, there is no joy in flight.
``` ```
@ -220,7 +217,7 @@ The preceding blockquote will render as follows in the Hugo docs:
However, you can add a quick and easy `<cite>` element (added on the client via JavaScript) by separating your main blockquote and the citation with a hyphen with a single space on each side: However, you can add a quick and easy `<cite>` element (added on the client via JavaScript) by separating your main blockquote and the citation with a hyphen with a single space on each side:
``` ```md
> Without the threat of punishment, there is no joy in flight. - [Kobo Abe](https://en.wikipedia.org/wiki/Kobo_Abe) > Without the threat of punishment, there is no joy in flight. - [Kobo Abe](https://en.wikipedia.org/wiki/Kobo_Abe)
``` ```

View file

@ -4,7 +4,6 @@ linktitle: Themes
description: If you've built a Hugo theme and want to contribute back to the Hugo Community, share it with us. description: If you've built a Hugo theme and want to contribute back to the Hugo Community, share it with us.
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-27
categories: [contribute] categories: [contribute]
keywords: [contribute,themes,design] keywords: [contribute,themes,design]
authors: [digitalcraftsman] authors: [digitalcraftsman]
@ -14,7 +13,6 @@ menu:
weight: 30 weight: 30
weight: 30 weight: 30
sections_weight: 30 sections_weight: 30
draft: false
aliases: [/contribute/theme/] aliases: [/contribute/theme/]
wip: true wip: true
toc: true toc: true

View file

@ -46,7 +46,7 @@ And since `Page` also provides a `.GetPage` method, the above is the same as:
## .GetPage and Multilingual Sites ## .GetPage and Multilingual Sites
The previous examples have used the full content filename to lookup the post. Depending on how you have organized your content (whether you have the language code in the file name or not, e.g. `my-post.en.md`), you may want to do the lookup without extension. This will get you the current language's version of the page: The previous examples have used the full content filename to look up the post. Depending on how you have organized your content (whether you have the language code in the file name or not, e.g. `my-post.en.md`), you may want to do the lookup without extension. This will get you the current language's version of the page:
```go-html-template ```go-html-template
{{ with .Site.GetPage "/blog/my-post" }}{{ .Title }}{{ end }} {{ with .Site.GetPage "/blog/my-post" }}{{ .Title }}{{ end }}

View file

@ -10,8 +10,6 @@ keywords: [markdown,goldmark,render]
signature: [".RenderString MARKUP"] signature: [".RenderString MARKUP"]
--- ---
{{< new-in "0.62.0" >}}
`.RenderString` is a method on `Page` that renders some markup to HTML using the content renderer defined for that page (if not set in the options). `.RenderString` is a method on `Page` that renders some markup to HTML using the content renderer defined for that page (if not set in the options).
The method takes an optional map argument with these options: The method takes an optional map argument with these options:
@ -32,5 +30,4 @@ Some examples:
{{ "/italic org mode/" | $p.RenderString $optOrg }} {{ "/italic org mode/" | $p.RenderString $optOrg }}
``` ```
{{< new-in "0.93.0" >}} **Note**: [markdownify](/functions/markdownify/) uses this function in order to support [Render Hooks](/getting-started/configuration-markup/#markdown-render-hooks).
**Note** that this method is more powerful than the similar [markdownify](/functions/markdownify/) function as it also supports [Render Hooks](/getting-started/configuration-markup/#markdown-render-hooks) and it has options to render other markup formats.

View file

@ -1,27 +1,61 @@
--- ---
title: absLangURL title: absLangURL
description: Adds the absolute URL with correct language prefix according to site configuration for multilingual. description: Returns an absolute URL with a language prefix, if any.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: functions
keywords: [multilingual,i18n,urls] keywords: [urls, multilingual,i18n]
signature: ["absLangURL INPUT"] signature: ["absLangURL INPUT"]
workson: []
hugoversion:
relatedfuncs: [relLangURL]
deprecated: false
aliases: []
--- ---
Both `absLangURL` and [`relLangURL`](/functions/rellangurl/) are similar to their [`absURL`](/functions/absurl/) and [`relURL`](/functions/relurl) relatives but will add the correct language prefix when the site is configured with more than one language. Use this function with both monolingual and multilingual configurations. The URL returned by this function depends on:
So for a site `baseURL` set to `https://example.com/hugo/` and the current language is `en`: - Whether the input begins with a slash
- The `baseURL` in site configuration
- The language prefix, if any
In examples that follow, the project is multilingual with content in both Español (`es`) and English (`en`). The default language is Español. The returned values are from the English site.
### Input does not begin with a slash
If the input does not begin with a slash, the resulting URL will be correct regardless of the `baseURL`.
With `baseURL = https://example.org/`
```go-html-template
{{ absLangURL "" }} → https://example.org/en/
{{ absLangURL "articles" }} → https://example.org/en/articles
{{ absLangURL "style.css" }} → https://example.org/en/style.css
``` ```
{{ "blog/" | absLangURL }} → "https://example.com/hugo/en/blog/"
{{ "blog/" | relLangURL }} → "/hugo/en/blog/" With `baseURL = https://example.org/docs/`
```go-html-template
{{ absLangURL "" }} → https://example.org/docs/en/
{{ absLangURL "articles" }} → https://example.org/docs/en/articles
{{ absLangURL "style.css" }} → https://example.org/docs/en/style.css
``` ```
### Input begins with a slash
If the input begins with a slash, the resulting URL will be incorrect when the `baseURL` includes a subdirectory. With a leading slash, the function returns a URL relative to the protocol+host section of the `baseURL`.
With `baseURL = https://example.org/`
```go-html-template
{{ absLangURL "/" }} → https://example.org/en/
{{ absLangURL "/articles" }} → https://example.org/en/articles
{{ absLangURL "/style.css" }} → https://example.org/en/style.css
```
With `baseURL = https://example.org/docs/`
```go-html-template
{{ absLangURL "/" }} → https://example.org/en/
{{ absLangURL "/articles" }} → https://example.org/en/articles
{{ absLangURL "/style.css" }} → https://example.org/en/style.css
{{% note %}}
The last three examples are not desirable in most situations. As a best practice, never include a leading slash when using this function.
{{% /note %}}

View file

@ -1,50 +1,61 @@
--- ---
title: absURL title: absURL
description: Creates an absolute URL based on the configured baseURL. description: Returns an absolute URL.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: functions
keywords: [urls] keywords: [urls]
signature: ["absURL INPUT"] signature: ["absURL INPUT"]
workson: []
hugoversion:
relatedfuncs: [relURL]
deprecated: false
aliases: []
--- ---
Both `absURL` and `relURL` consider the configured value of `baseURL` in your site's [`config` file][configuration]. Given a `baseURL` set to `https://example.com/hugo/`: With multilingual configurations, use the [`absLangURL`] function instead. The URL returned by this function depends on:
``` - Whether the input begins with a slash
{{ "mystyle.css" | absURL }} → "https://example.com/hugo/mystyle.css" - The `baseURL` in site configuration
{{ "mystyle.css" | relURL }} → "/hugo/mystyle.css"
{{ "http://gohugo.io/" | relURL }} → "http://gohugo.io/" ### Input does not begin with a slash
{{ "http://gohugo.io/" | absURL }} → "http://gohugo.io/"
If the input does not begin with a slash, the resulting URL will be correct regardless of the `baseURL`.
With `baseURL = https://example.org/`
```go-html-template
{{ absURL "" }} → https://example.org/
{{ absURL "articles" }} → https://example.org/articles
{{ absURL "style.css" }} → https://example.org/style.css
``` ```
The last two examples may look strange but can be very useful. For example, the following shows how to use `absURL` in [JSON-LD structured data (SEO)][jsonld], where some of your images for a piece of content may or may not be hosted locally: With `baseURL = https://example.org/docs/`
{{< code file="layouts/partials/schemaorg-metadata.html" download="schemaorg-metadata.html" >}} ```go-html-template
<script type="application/ld+json"> {{ absURL "" }} → https://example.org/docs/
{ {{ absURL "articles" }} → https://example.org/docs/articles
"@context" : "http://schema.org", {{ absURL "style.css" }} → https://example.org/docs/style.css
"@type" : "BlogPosting", ```
"image" : {{ apply .Params.images "absURL" "." }}
}
</script>
{{< /code >}}
The above uses the [apply function][] and also exposes how the Go template parser JSON-encodes objects inside `<script>` tags. See [the safeJS template function][safejs] for examples of how to tell Hugo not to escape strings inside of such tags. ### Input begins with a slash
{{% note "Ending Slash" %}} If the input begins with a slash, the resulting URL will be incorrect when the `baseURL` includes a subdirectory. With a leading slash, the function returns a URL relative to the protocol+host section of the `baseURL`.
`absURL` and `relURL` are smart about missing slashes, but they will *not* add a closing slash to a URL if it is not present.
With `baseURL = https://example.org/`
```go-html-template
{{ absURL "/" }} → https://example.org/
{{ absURL "/articles" }} → https://example.org/articles
{{ absURL "/style.css" }} → https://example.org/style.css
```
With `baseURL = https://example.org/docs/`
```go-html-template
{{ absURL "/" }} → https://example.org/
{{ absURL "/articles" }} → https://example.org/articles
{{ absURL "/style.css" }} → https://example.org/style.css
```
{{% note %}}
The last three examples are not desirable in most situations. As a best practice, never include a leading slash when using this function.
{{% /note %}} {{% /note %}}
[apply function]: /functions/apply/ [`absLangURL`]: /functions/abslangurl/
[configuration]: /getting-started/configuration/
[jsonld]: https://developers.google.com/search/docs/guides/intro-structured-data
[safejs]: /functions/safejs

View file

@ -1,29 +1,80 @@
--- ---
title: "complement" title: complement
description: "`collections.Complement` (alias `complement`) gives the elements of a collection that are not in any of the others." description: Returns the elements of the last collection that are not in any of the others.
date: 2018-11-07
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: functions
keywords: [collections,intersect,union] keywords: [collections]
signature: ["COLLECTION | complement COLLECTION [COLLECTION]..." ] signature:
hugoversion: "0.51" - "complement COLLECTION [COLLECTION]..."
- "collections.Complement COLLECTION [COLLECTION]..."
relatedfuncs: [intersect,symdiff,union]
aliases: [] aliases: []
--- ---
Example: To find the elements within `$c3` that do not exist in `$c1` or `$c2`:
```go-html-template ```go-html-template
{{ $pages := site.RegularPages | first 50 }} {{ $c1 := slice 3 }}
{{ $news := where $pages "Type" "news" | first 5 }} {{ $c2 := slice 4 5 }}
{{ $blog := where $pages "Type" "blog" | first 5 }} {{ $c3 := slice 1 2 3 4 5 }}
{{ $other := $pages | complement $news $blog | first 10 }}
{{ complement $c1 $c2 $c3 }} → [1 2]
``` ```
The above is an imaginary use case for the home page where you want to display different page listings in sections/boxes on different places on the page: 5 from `news`, 5 from the `blog` and then 10 of the pages not shown in the other listings, to _complement_ them. {{% note %}}
Make your code simpler to understand by using a [chained pipeline]:
[chained pipeline]: https://pkg.go.dev/text/template#hdr-Pipelines
{{% /note %}}
```go-html-template
{{ $c3 | complement $c1 $c2 }} → [1 2]
```
You can also use the `complement` function with page collections. Let's say your site has five content types:
```text
content/
├── blog/
├── books/
├── faqs/
├── films/
└── songs/
```
To list everything except blog articles (`blog`) and frequently asked questions (`faqs`):
```go-html-template
{{ $blog := where site.RegularPages "Type" "blog" }}
{{ $faqs := where site.RegularPages "Type" "faqs" }}
{{ range site.RegularPages | complement $blog $faqs }}
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}
```
{{% note %}}
Although the example above demonstrates the `complement` function, you could use the [`where`] function as well:
[`where`]: /functions/where/
{{% /note %}}
```go-html-template
{{ range where site.RegularPages "Type" "not in" (slice "blog" "faqs") }}
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}
```
In this example we use the `complement` function to remove [stop words] from a sentence:
```go-html-template
{{ $text := "The quick brown fox jumps over the lazy dog" }}
{{ $stopWords := slice "a" "an" "in" "over" "the" "under" }}
{{ $filtered := split $text " " | complement $stopWords }}
{{ delimit $filtered " " }} → The quick brown fox jumps lazy dog
```
[stop words]: https://en.wikipedia.org/wiki/Stop_word

View file

@ -22,7 +22,7 @@ deprecated: false
{{ time.Format "Monday, Jan 2, 2006" "2015-01-21" }} → "Wednesday, Jan 21, 2015" {{ time.Format "Monday, Jan 2, 2006" "2015-01-21" }} → "Wednesday, Jan 21, 2015"
``` ```
Note that since Hugo 0.87.0, `time.Format` will return a localized string for the current language. {{< new-in "0.87.0" >}} `time.Format` returns a localized string for the current language.
The `LAYOUT` string can be either: The `LAYOUT` string can be either:
@ -34,9 +34,7 @@ See the [`time` function](/functions/time/) to convert a timestamp string to a G
## Date/time formatting layouts ## Date/time formatting layouts
{{< new-in "0.87.0" >}} Go's date layout strings can be hard to reason about, especially with multiple languages. You can alternatively use some predefined layout identifiers that will output localized dates or times:
Go's date layout strings can be hard to reason about, especially with multiple languages. Since Hugo 0.87.0 you can alternatively use some predefined layout identifiers that will output localized dates or times:
```go-html-template ```go-html-template
{{ .Date | time.Format ":date_long" }} {{ .Date | time.Format ":date_long" }}

View file

@ -3,7 +3,6 @@ title: dict
description: Creates a dictionary from a list of key and value pairs. description: Creates a dictionary from a list of key and value pairs.
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-26
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
@ -25,21 +24,20 @@ Note that the `key` can be either a `string` or a `string slice`. The latter is
{{ $m := dict (slice "a" "b" "c") "value" }} {{ $m := dict (slice "a" "b" "c") "value" }}
``` ```
## Example: Using `dict` to pass multiple values to a `partial` ## Example: Using `dict` to pass multiple values to a `partial`
The partial below creates a SVG and expects `fill`, `height` and `width` from the caller: The partial below creates an SVG and expects `fill`, `height` and `width` from the caller:
**Partial definition** ### Partial definition
{{< code file="layouts/partials/svgs/external-links.svg" download="external-links.svg" >}} {{< code file="layouts/partials/svgs/external-links.svg" download="external-links.svg" >}}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
fill="{{ .fill }}" width="{{ .width }}" height="{{ .height }}" viewBox="0 0 32 32" aria-label="External Link"> fill="{{ .fill }}" width="{{ .width }}" height="{{ .height }}" viewBox="0 0 32 32" aria-label="External Link">
<path d="M25.152 16.576v5.696q0 2.144-1.504 3.648t-3.648 1.504h-14.848q-2.144 0-3.648-1.504t-1.504-3.648v-14.848q0-2.112 1.504-3.616t3.648-1.536h12.576q0.224 0 0.384 0.16t0.16 0.416v1.152q0 0.256-0.16 0.416t-0.384 0.16h-12.576q-1.184 0-2.016 0.832t-0.864 2.016v14.848q0 1.184 0.864 2.016t2.016 0.864h14.848q1.184 0 2.016-0.864t0.832-2.016v-5.696q0-0.256 0.16-0.416t0.416-0.16h1.152q0.256 0 0.416 0.16t0.16 0.416zM32 1.152v9.12q0 0.48-0.352 0.8t-0.8 0.352-0.8-0.352l-3.136-3.136-11.648 11.648q-0.16 0.192-0.416 0.192t-0.384-0.192l-2.048-2.048q-0.192-0.16-0.192-0.384t0.192-0.416l11.648-11.648-3.136-3.136q-0.352-0.352-0.352-0.8t0.352-0.8 0.8-0.352h9.12q0.48 0 0.8 0.352t0.352 0.8z"></path> <path d="M25.152 16.576v5.696q0 2.144-1.504 3.648t-3.648 1.504h-14.848q-2.144 0-3.648-1.504t-1.504-3.648v-14.848q0-2.112 1.504-3.616t3.648-1.536h12.576q0.224 0 0.384 0.16t0.16 0.416v1.152q0 0.256-0.16 0.416t-0.384 0.16h-12.576q-1.184 0-2.016 0.832t-0.864 2.016v14.848q0 1.184 0.864 2.016t2.016 0.864h14.848q1.184 0 2.016-0.864t0.832-2.016v-5.696q0-0.256 0.16-0.416t0.416-0.16h1.152q0.256 0 0.416 0.16t0.16 0.416zM32 1.152v9.12q0 0.48-0.352 0.8t-0.8 0.352-0.8-0.352l-3.136-3.136-11.648 11.648q-0.16 0.192-0.416 0.192t-0.384-0.192l-2.048-2.048q-0.192-0.16-0.192-0.384t0.192-0.416l11.648-11.648-3.136-3.136q-0.352-0.352-0.352-0.8t0.352-0.8 0.8-0.352h9.12q0.48 0 0.8 0.352t0.352 0.8z"></path>
</svg> </svg>
{{< /code >}} {{< /code >}}
**Partial call** ### Partial call
The `fill`, `height` and `width` values can be stored in one object with `dict` and passed to the partial: The `fill`, `height` and `width` values can be stored in one object with `dict` and passed to the partial:
@ -47,6 +45,4 @@ The `fill`, `height` and `width` values can be stored in one object with `dict`
{{ partial "svgs/external-links.svg" (dict "fill" "#01589B" "width" 10 "height" 20 ) }} {{ partial "svgs/external-links.svg" (dict "fill" "#01589B" "width" 10 "height" 20 ) }}
{{< /code >}} {{< /code >}}
[partials]: /templates/partials/ [partials]: /templates/partials/

View file

@ -30,7 +30,7 @@ Both functions return an empty string, so the messages are only printed to the c
{{ warnf "You should update the shortcodes in %q" .Path }} {{ warnf "You should update the shortcodes in %q" .Path }}
``` ```
Note that `errorf`, `erroridf`, and `warnf` support all the formatting verbs of the [fmt](https://golang.org/pkg/fmt/) package. Note that `errorf`, `erroridf`, and `warnf` support all the formatting verbs of the [fmt](https://pkg.go.dev/fmt) package.
## Suppress errors ## Suppress errors

View file

@ -1,44 +1,40 @@
--- ---
title: findRE title: findRE
description: Returns a list of strings that match the regular expression. description: Returns a slice of strings that match the regular expression.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: functions
keywords: [regex] keywords: [regex]
signature: ["findRE PATTERN INPUT [LIMIT]"] signature:
workson: [] - "findRE PATTERN INPUT [LIMIT]"
hugoversion: - "strings.FindRE PATTERN INPUT [LIMIT]"
relatedfuncs: [] relatedfuncs: [replaceRE]
deprecated: false
aliases: [] aliases: []
--- ---
By default, the `findRE` function finds all matches. You can limit the number of matches with an optional LIMIT paramater.
By default all matches will be included. The number of matches can be limited with an optional third parameter. When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes.
The example below returns a list of all second level headers (`<h2>`) in the content: The syntax of the regular expression is the same general syntax used by Perl, Python, and other languages. More precisely, it is the syntax accepted by [RE2] except for `\C`.
``` This example returns a slice of all second level headings (`h2` elements) within the rendered `.Content`:
{{ findRE "<h2.*?>(.|\n)*?</h2>" .Content }}
```go-html-template
{{ findRE `(?s)<h2.*?>.*?</h2>` .Content }}
``` ```
You can limit the number of matches in the list with a third parameter. The following example shows how to limit the returned value to just one match (or none, if there are no matched substrings): The `s` flag causes `.` to match `\n` as well, allowing us to find an `h2` element that contains newlines.
``` To limit the number of matches to one:
{{ findRE "<h2.*?>(.|\n)*?</h2>" .Content 1 }}
<!-- returns ["<h2 id="#foo">Foo</h2>"] --> ```go-html-template
{{ findRE `(?s)<h2.*?>.*?</h2>` .Content 1 }}
``` ```
{{% note %}} {{% note %}}
Hugo uses Go's [Regular Expression package](https://golang.org/pkg/regexp/), which is the same general syntax used by Perl, Python, and other languages but with a few minor differences for those coming from a background in PCRE. For a full syntax listing, see the [GitHub wiki for re2](https://github.com/google/re2/wiki/Syntax). You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
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 %}} {{% /note %}}
[partials]: /templates/partials/ [RE2]: https://github.com/google/re2/wiki/Syntax
[`plainify`]: /functions/plainify/ [string literal]: https://go.dev/ref/spec#String_literals
[toc]: /content-management/toc/
[`urlize`]: /functions/urlize

View file

@ -93,7 +93,7 @@ More examples can be found in Go's [documentation for the time package][timecons
### Cardinal Numbers and Ordinal Abbreviations ### Cardinal Numbers and Ordinal Abbreviations
Spelled-out cardinal numbers (e.g. "one", "two", and "three") are not currently supported. Spelled-out cardinal numbers (e.g. "one", "two", and "three") are not currently supported.
Ordinal abbreviations (i.e., with shorted suffixes like "1st", "2nd", and "3rd") are not currently directly supported. By using `{{.Date.Format "Jan 2nd 2006"}}`, Hugo assumes you want to append `nd` as a string to the day of the month. However, you can chain functions together to create something like this: Ordinal abbreviations (i.e., with shorted suffixes like "1st", "2nd", and "3rd") are not currently directly supported. By using `{{.Date.Format "Jan 2nd 2006"}}`, Hugo assumes you want to append `nd` as a string to the day of the month. However, you can chain functions together to create something like this:

View file

@ -18,12 +18,11 @@ aliases: []
needsexample: true needsexample: true
--- ---
`.Get` is specifically used when creating your own [shortcode template][sc], to access the [positional and named](/templates/shortcode-templates/#positional-vs-named-parameters) parameters passed to it. When used with a numeric INDEX, it queries positional parameters (starting with 0). With a string KEY, it queries named parameters. `.Get` is specifically used when creating your own [shortcode template][sc], to access the [positional and named](/templates/shortcode-templates/#positional-vs-named-parameters) parameters passed to it. When used with a numeric INDEX, it queries positional parameters (starting with 0). With a string KEY, it queries named parameters.
When accessing a named parameter that does not exist, `.Get` returns an empty string instead of interrupting the build. The same goes with positional parameters in hugo version 0.40 and after. This allows you to chain `.Get` with `if`, `with`, `default` or `cond` to check for parameter existence. For example, you may now use: When accessing named or positional parameters that do not exist, `.Get` returns an empty string instead of interrupting the build. This allows you to chain `.Get` with `if`, `with`, `default` or `cond` to check for parameter existence. For example:
``` ```go-html-template
{{ $quality := default "100" (.Get 1) }} {{ $quality := default "100" (.Get 1) }}
``` ```

View file

@ -41,3 +41,6 @@ And then retrieve the values within a template:
{{ os.Getenv "MY_VAR1" }} --> foo {{ os.Getenv "MY_VAR1" }} --> foo
{{ os.Getenv "MY_VAR2" }} --> bar {{ os.Getenv "MY_VAR2" }} --> bar
``` ```
With Hugo v0.91.0 and later, you must explicitly allow access to environment variables. For details, review [Hugo's Security Policy](/about/security-model/#security-policy). By default, environment variables beginning with `HUGO_` are allowed when using the `os.Getenv` function.

View file

@ -1,22 +0,0 @@
---
title: .HasChildren
description:
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [menus]
toc:
signature: ["HasChildren"]
workson: [menus]
hugoversion:
relatedfuncs: []
deprecated: false
draft: true
aliases: []
---
Used in [menu templates](/templates/menu-templates/).

View file

@ -23,6 +23,6 @@ aliases: []
returns `true` if the PAGE is the same object as the `.Page` in one of the returns `true` if the PAGE is the same object as the `.Page` in one of the
**children menu entries** under MENUENTRY in a given MENU. **children menu entries** under MENUENTRY in a given MENU.
{{< new-in "0.86.0" >}} If MENUENTRY's `.Page` is a [section](/content-management/sections/) then, from Hugo `0.86.0`, this method also returns true for any descendant of that section.. If MENUENTRY's `.Page` is a [section](/content-management/sections/) then, from Hugo `0.86.0`, this method also returns true for any descendant of that section..
You can find its example use in [menu templates](/templates/menu-templates/). You can find its example use in [menu templates](/templates/menu-templates/).

View file

@ -77,10 +77,10 @@ If the `LANG` parameter is blank or an unrecognized language, auto-detect the la
{{% note %}} {{% note %}}
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation: Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
`lineNos=inline` `lineNos=inline`
: equivalent to `lineNos=true` and `lineNumbersInTable=false` : equivalent to `lineNos=true` and `lineNumbersInTable=false`
`lineNos=table` `lineNos=table`
: equivalent to `lineNos=true` and `lineNumbersInTable=true` : equivalent to `lineNos=true` and `lineNumbersInTable=true`
{{% /note %}} {{% /note %}}

View file

@ -22,10 +22,10 @@ aliases: []
`hugo` returns an instance that contains the following functions: `hugo` returns an instance that contains the following functions:
hugo.Generator hugo.Generator
: `<meta>` tag for the version of Hugo that generated the site. `hugo.Generator` outputs a *complete* HTML tag; e.g. `<meta name="generator" content="Hugo 0.63.2" />` : `<meta>` tag for the version of Hugo that generated the site. `hugo.Generator` outputs a *complete* HTML tag; e.g. `<meta name="generator" content="Hugo 0.99.1" />`
hugo.Version hugo.Version
: the current version of the Hugo binary you are using e.g. `0.63.2` : the current version of the Hugo binary you are using e.g. `0.99.1`
hugo.GoVersion hugo.GoVersion
: returns the version of Go that the Hugo binary was built with. {{< new-in "0.101.0" >}} : returns the version of Go that the Hugo binary was built with. {{< new-in "0.101.0" >}}
@ -39,7 +39,7 @@ hugo.CommitHash
hugo.BuildDate hugo.BuildDate
: the compile date of the current Hugo binary formatted with RFC 3339 e.g. `2002-10-02T10:00:00-05:00` : the compile date of the current Hugo binary formatted with RFC 3339 e.g. `2002-10-02T10:00:00-05:00`
hugo.IsExtended {{< new-in "0.83.0" >}} hugo.IsExtended
: whether this is the extended Hugo binary. : whether this is the extended Hugo binary.
hugo.IsProduction hugo.IsProduction

View file

@ -15,8 +15,6 @@ See [images.Filter](#filter) for how to apply these filters to an image.
## Overlay ## Overlay
{{< new-in "0.80.0" >}}
{{% funcsig %}} {{% funcsig %}}
images.Overlay SRC X Y images.Overlay SRC X Y
{{% /funcsig %}} {{% /funcsig %}}
@ -39,8 +37,6 @@ The above will overlay `$logo` in the upper left corner of `$img` (at position `
## Text ## Text
{{< new-in "0.90.0" >}}
Using the `Text` filter, you can add text to an image. Using the `Text` filter, you can add text to an image.
{{% funcsig %}} {{% funcsig %}}

View file

@ -38,7 +38,7 @@ this purpose.
{{ int ("00987" | strings.TrimLeft "0") }} {{ int ("00987" | strings.TrimLeft "0") }}
``` ```
**Explanation** ### Explanation
The `int` function eventually calls the `ParseInt` function from the Go library The `int` function eventually calls the `ParseInt` function from the Go library
`strconv`. `strconv`.

View file

@ -17,7 +17,7 @@ relatedfuncs: []
deprecated: false deprecated: false
aliases: [] aliases: []
--- ---
An useful example is to use it as `AND` filters when combined with where: A useful example is to use it as `AND` filters when combined with where:
## AND filter in where query ## AND filter in where query

View file

@ -32,6 +32,17 @@ more copies of *indent* according to the indentation nesting.
{{ dict "title" .Title "content" .Plain | jsonify (dict "prefix" " " "indent" " ") }} {{ dict "title" .Title "content" .Plain | jsonify (dict "prefix" " " "indent" " ") }}
``` ```
## Jsonify options
indent ("")
: Indentation to use.
prefix ("")
: Indentation prefix.
noHTMLEscape (false)
: Disable escaping of problematic HTML characters inside JSON quoted strings. The default behavior is to escape &, <, and > to \u0026, \u003c, and \u003e to avoid certain safety problems that can arise when embedding JSON in HTML.
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/

View file

@ -23,7 +23,6 @@ aliases: []
{{ .Title | markdownify }} {{ .Title | markdownify }}
``` ```
*Note*: if you need [Render Hooks][], which `markdownify` doesn't currently {{< new-in "0.93.0" >}} **Note**: `markdownify` now supports [Render Hooks][] just like [.RenderString](/functions/renderstring/).
support, use [.RenderString](/functions/renderstring/) instead.
[Render Hooks]: /getting-started/configuration-markup/#markdown-render-hooks [Render Hooks]: /templates/render-hooks/

View file

@ -25,6 +25,6 @@ aliases: []
This can be useful if you want to use [Gravatar](https://en.gravatar.com/) for generating a unique avatar: This can be useful if you want to use [Gravatar](https://en.gravatar.com/) for generating a unique avatar:
``` ```html
<img src="https://www.gravatar.com/avatar/{{ md5 "your@email.com" }}?s=100&d=identicon"> <img src="https://www.gravatar.com/avatar/{{ md5 "your@email.com" }}?s=100&d=identicon">
``` ```

View file

@ -43,4 +43,4 @@ If you need to pass additional parameters to create unique variants, you can pas
Note that the variant parameters are not made available to the underlying partial template. They are only use to create a unique cache key. Since Hugo `0.61.0` you can use any object as cache key(s), not just strings. Note that the variant parameters are not made available to the underlying partial template. They are only use to create a unique cache key. Since Hugo `0.61.0` you can use any object as cache key(s), not just strings.
> See also the [The Full Partial Series Part 1: Caching!](https://regisphilibert.com/blog/2019/12/hugo-partial-series-part-1-caching-with-partialcached/) > See also [The Full Partial Series Part 1: Caching!](https://regisphilibert.com/blog/2019/12/hugo-partial-series-part-1-caching-with-partialcached/)

View file

@ -45,6 +45,6 @@ To return the absolute permalink to another Output Format of a page:
{{ ref . (dict "path" "about.md" "outputFormat" "rss") }} {{ ref . (dict "path" "about.md" "outputFormat" "rss") }}
``` ```
Hugo emits an error or warning if the page cannot be uniquely resolved. The error behavior is configurable; see [Ref and RelRef Configuration](/content-management/cross-references/#ref-and-relref-configuration). Hugo emits an error or warning if the page cannot be uniquely resolved. The error behavior is configurable; see [Ref and RelRef Configuration](/content-management/cross-references/#ref-and-relref-configuration).
This function is used by Hugo's built-in [`ref`](/content-management/shortcodes/#ref-and-relref) shortcode. For a detailed explanation of how to leverage this shortcode for content management, see [Links and Cross References](/content-management/cross-references/). This function is used by Hugo's built-in [`ref`](/content-management/shortcodes/#ref-and-relref) shortcode. For a detailed explanation of how to leverage this shortcode for content management, see [Links and Cross References](/content-management/cross-references/).

View file

@ -1,29 +1,62 @@
--- ---
title: relLangURL title: relLangURL
description: Adds the relative URL with correct language prefix according to site configuration for multilingual. description: Returns a relative URL with a language prefix, if any.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
keywords: [multilingual,i18n,urls]
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: functions
keywords: [urls, multilingual,i18n]
signature: ["relLangURL INPUT"] signature: ["relLangURL INPUT"]
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
aliases: []
--- ---
`absLangURL` and `relLangURL` functions are similar to their [`absURL`](/functions/absurl/) and [`relURL`](/functions/relurl/) relatives but will add the correct language prefix when the site is configured with more than one language. (See [Configure Languages][multiliconfig].) Use this function with both monolingual and multilingual configurations. The URL returned by this function depends on:
So for a site `baseURL` set to `https://example.com/hugo/` and the current language is `en`: - Whether the input begins with a slash
- The `baseURL` in site configuration
- The language prefix, if any
``` In examples that follow, the project is multilingual with content in both Español (`es`) and English (`en`). The default language is Español. The returned values are from the English site.
{{ "blog/" | absLangURL }} → "https://example.com/hugo/en/blog/"
{{ "blog/" | relLangURL }} → "/hugo/en/blog/" ### Input does not begin with a slash
If the input does not begin with a slash, the resulting URL will be correct regardless of the `baseURL`.
With `baseURL = https://example.org/`
```go-html-template
{{ relLangURL "" }} → /en/
{{ relLangURL "articles" }} → /en/articles
{{ relLangURL "style.css" }} → /en/style.css
```
With `baseURL = https://example.org/docs/`
```go-html-template
{{ relLangURL "" }} → /docs/en/
{{ relLangURL "articles" }} → /docs/en/articles
{{ relLangURL "style.css" }} → /docs/en/style.css
``` ```
[multiliconfig]: /content-management/multilingual/#configure-languages ### Input begins with a slash
If the input begins with a slash, the resulting URL will be incorrect when the `baseURL` includes a subdirectory. With a leading slash, the function returns a URL relative to the protocol+host section of the `baseURL`.
With `baseURL = https://example.org/`
```go-html-template
{{ relLangURL "/" }} → /en/
{{ relLangURL "/articles" }} → /en/articles
{{ relLangURL "/style.css" }} → /en/style.css
```
With `baseURL = https://example.org/docs/`
```go-html-template
{{ relLangURL "/" }} → /en/
{{ relLangURL "/articles" }} → /en/articles
{{ relLangURL "/style.css" }} → /en/style.css
```
{{% note %}}
The last three examples are not desirable in most situations. As a best practice, never include a leading slash when using this function.
{{% /note %}}

View file

@ -52,6 +52,6 @@ To return the relative permalink to another Output Format of a page:
{{ relref . (dict "path" "about.md" "outputFormat" "rss") }} {{ relref . (dict "path" "about.md" "outputFormat" "rss") }}
``` ```
Hugo emits an error or warning if the page cannot be uniquely resolved. The error behavior is configurable; see [Ref and RelRef Configuration](/content-management/cross-references/#ref-and-relref-configuration). Hugo emits an error or warning if the page cannot be uniquely resolved. The error behavior is configurable; see [Ref and RelRef Configuration](/content-management/cross-references/#ref-and-relref-configuration).
This function is used by Hugo's built-in [`relref`](/content-management/shortcodes/#ref-and-relref) shortcode. For a detailed explanation of how to leverage this shortcode for content management, see [Links and Cross References](/content-management/cross-references/). This function is used by Hugo's built-in [`relref`](/content-management/shortcodes/#ref-and-relref) shortcode. For a detailed explanation of how to leverage this shortcode for content management, see [Links and Cross References](/content-management/cross-references/).

View file

@ -1,49 +1,61 @@
--- ---
title: relURL title: relURL
description: Creates a baseURL-relative URL. description: Returns a relative URL.
date: 2017-02-01
publishdate: 2017-02-01
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: functions
keywords: [urls] keywords: [urls]
signature: ["relURL INPUT"] signature: ["relURL INPUT"]
workson: []
hugoversion:
relatedfuncs: [absURL]
deprecated: false
aliases: []
--- ---
Both `absURL` and `relURL` consider the configured value of `baseURL` in your site's [`config` file][configuration]. Given a `baseURL` set to `https://example.com/hugo/`: With multilingual configurations, use the [`relLangURL`] function instead. The URL returned by this function depends on:
``` - Whether the input begins with a slash
{{ "mystyle.css" | absURL }} → "https://example.com/hugo/mystyle.css" - The `baseURL` in site configuration
{{ "mystyle.css" | relURL }} → "/hugo/mystyle.css"
{{ "http://gohugo.io/" | relURL }} → "http://gohugo.io/" ### Input does not begin with a slash
{{ "http://gohugo.io/" | absURL }} → "http://gohugo.io/"
If the input does not begin with a slash, the resulting URL will be correct regardless of the `baseURL`.
With `baseURL = https://example.org/`
```go-html-template
{{ relURL "" }} → /
{{ relURL "articles" }} → /articles
{{ relURL "style.css" }} → /style.css
``` ```
The last two examples may look strange but can be very useful. For example, the following shows how to use `absURL` in [JSON-LD structured data for SEO][jsonld] where some of your images for a piece of content may or may not be hosted locally: With `baseURL = https://example.org/docs/`
{{< code file="layouts/partials/schemaorg-metadata.html" download="schemaorg-metadata.html" >}} ```go-html-template
<script type="application/ld+json"> {{ relURL "" }} → /docs/
{ {{ relURL "articles" }} → /docs/articles
"@context" : "https://schema.org", {{ relURL "style.css" }} → /docs/style.css
"@type" : "BlogPosting", ```
"image" : {{ apply .Params.images "absURL" "." }}
}
</script>
{{< /code >}}
The above uses the [apply function][] and also exposes how the Go template parser JSON-encodes objects inside `<script>` tags. See [the safeJS template function][safejs] for examples of how to tell Hugo not to escape strings inside of such tags. ### Input begins with a slash
{{% note "Ending Slash" %}} If the input begins with a slash, the resulting URL will be incorrect when the `baseURL` includes a subdirectory. With a leading slash, the function returns a URL relative to the protocol+host section of the `baseURL`.
`absURL` and `relURL` are smart about missing slashes, but they will *not* add a closing slash to a URL if it is not present.
With `baseURL = https://example.org/`
```go-html-template
{{ relURL "/" }} → /
{{ relURL "/articles" }} → /articles
{{ relURL "style.css" }} → /style.css
```
With `baseURL = https://example.org/docs/`
```go-html-template
{{ relURL "/" }} → /
{{ relURL "/articles" }} → /articles
{{ relURL "/style.css" }} → /style.css
```
{{% note %}}
The last three examples are not desirable in most situations. As a best practice, never include a leading slash when using this function.
{{% /note %}} {{% /note %}}
[apply function]: /functions/apply/ [`relLangURL`]: /functions/rellangurl/
[configuration]: /getting-started/configuration/
[jsonld]: https://developers.google.com/search/docs/advanced/structured-data/intro-structured-data
[safejs]: /functions/safejs

View file

@ -1,34 +1,47 @@
--- ---
title: replaceRE title: replaceRE
description: Replaces all occurrences of a regular expression with the replacement pattern. description: Returns a string, replacing all occurrences of a regular expression with a replacement pattern.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2020-09-07
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: functions
keywords: [regex] keywords: [regex]
signature: ["strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]", "replaceRE PATTERN REPLACEMENT INPUT [LIMIT]"] signature:
workson: [] - "replaceRE PATTERN REPLACEMENT INPUT [LIMIT]"
hugoversion: - "strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]"
relatedfuncs: [] relatedfuncs: [findRE]
deprecated: false
aliases: [] aliases: []
--- ---
By default, the `replaceRE` function replaces all matches. You can limit the number of matches with an optional LIMIT paramater.
`strings.ReplaceRE` returns a copy of `INPUT`, replacing all matches of the regular When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes.
expression `PATTERN` with the replacement text `REPLACEMENT`.
The number of replacements can be limited with an optional `LIMIT` parameter.
The syntax of the regular expression is the same general syntax used by Perl, Python, and other languages. More precisely, it is the syntax accepted by [RE2] except for `\C`.
This example replaces two or more consecutive hyphens with a single hyphen:
```go-html-template
{{ $s := "a-b--c---d" }}
{{ replaceRE `(-{2,})` "-" $s }} → a-b-c-d
``` ```
{{ replaceRE "^https?://([^/]+).*" "$1" "http://gohugo.io/docs" }}` → "gohugo.io"
{{ "http://gohugo.io/docs" | replaceRE "^https?://([^/]+).*" "$1" }}` → "gohugo.io" To limit the number of replacements to one:
{{ replaceRE "a+b" "X" "aabbaabbab" 1 }} → "Xbaabbab"
```go-html-template
{{ $s := "a-b--c---d" }}
{{ replaceRE `(-{2,})` "-" $s 1 }} → a-b-c---d
```
You can use `$1`, `$2`, etc. within the replacement string to insert the groups captured within the regular expression:
```go-html-template
{{ $s := "http://gohugo.io/docs" }}
{{ replaceRE "^https?://([^/]+).*" "$1" $s }} → gohugo.io
``` ```
{{% note %}} {{% note %}}
Hugo uses Go's [Regular Expression package](https://golang.org/pkg/regexp/), which is the same general syntax used by Perl, Python, and other languages but with a few minor differences for those coming from a background in PCRE. For a full syntax listing, see the [GitHub wiki for re2](https://github.com/google/re2/wiki/Syntax). You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
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 %}} {{% /note %}}
[RE2]: https://github.com/google/re2/wiki/Syntax
[string literal]: https://go.dev/ref/spec#String_literals

View file

@ -27,7 +27,7 @@ copyright = "© 2015 Jane Doe. <a href=\"https://creativecommons.org/licenses/b
`{{ .Site.Copyright | safeHTML }}` in a template would then output: `{{ .Site.Copyright | safeHTML }}` in a template would then output:
``` ```html
© 2015 Jane Doe. <a href="https://creativecommons.org/licenses/by/4.0/">Some rights reserved</a>. © 2015 Jane Doe. <a href="https://creativecommons.org/licenses/by/4.0/">Some rights reserved</a>.
``` ```

View file

@ -1,30 +1,46 @@
--- ---
title: safeHTMLAttr title: safeHTMLAttr
# linktitle: safeHTMLAttr
description: Declares the provided string as a safe HTML attribute. description: Declares the provided string as a safe HTML attribute.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: functions
keywords: [strings] keywords: [strings]
signature: ["safeHTMLAttr INPUT"] signature: ["safeHTMLAttr INPUT"]
workson: []
hugoversion:
relatedfuncs: [] relatedfuncs: []
deprecated: false
aliases: [] aliases: []
--- ---
Example: Given a site-wide `config.toml` that contains this menu entry: Given a site configuration that contains this menu entry:
{{< code-toggle file="config" >}} {{< code-toggle file="config" >}}
[[menu.main]] [[menu.main]]
name = "IRC: #golang at freenode" name = "IRC"
url = "irc://irc.freenode.net/#golang" url = "irc://irc.freenode.net/#golang"
{{< /code-toggle >}} {{< /code-toggle >}}
* <span class="bad">`<a href="{{ .URL }}">` &rarr; `<a href="#ZgotmplZ">`</span> Attempting to use the `url` value directly in an attribute:
* <span class="good">`<a {{ printf "href=%q" .URL | safeHTMLAttr }}>` &rarr; `<a href="irc://irc.freenode.net/#golang">`</span>
```go-html-template
{{ range site.Menus.main }}
<a href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
```
Will produce:
```html
<a href="#ZgotmplZ">IRC</a>
```
`ZgotmplZ` is a special value, inserted by Go's [template/html] package, that indicates that unsafe content reached a CSS or URL context.
To override the safety check, use the `safeHTMLAttr` function:
```go-html-template
{{ range site.Menus.main }}
<a {{ printf "href=%q" .URL | safeHTMLAttr }}>{{ .Name }}</a>
{{ end }}
```
[template/html]: https://pkg.go.dev/html/template

View file

@ -42,7 +42,7 @@ Since Hugo 0.43, there are two different ways of using Scratch:
#### The local `newScratch` #### The local `newScratch`
{{< new-in "0.43" >}} A Scratch instance can also be assigned to any variable using the `newScratch` function. In this case, no Page or Shortcode context is required and the scope of the scratch is only local. The methods detailed below are available from the variable the Scratch instance was assigned to. A Scratch instance can also be assigned to any variable using the `newScratch` function. In this case, no Page or Shortcode context is required and the scope of the scratch is only local. The methods detailed below are available from the variable the Scratch instance was assigned to.
```go-html-template ```go-html-template
{{ $data := newScratch }} {{ $data := newScratch }}
@ -77,7 +77,7 @@ Get the value of a given key.
#### .Add #### .Add
Add a given value to existing value(s) of the given key. Add a given value to existing value(s) of the given key.
For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list.
@ -138,7 +138,7 @@ Return an array of values from `key` sorted by `mapKey`.
#### .Delete #### .Delete
{{< new-in "0.38" >}} Remove the given key. Remove the given key.
```go-html-template ```go-html-template
{{ $scratch.Set "greeting" "Hello" }} {{ $scratch.Set "greeting" "Hello" }}

View file

@ -1,10 +1,9 @@
--- ---
title: split title: split
# linktitle: split description: Returns a slice of strings by splitting STRING by DELIM.
description: splits a string into substrings separated by a delimiter
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2022-11-06
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
@ -18,4 +17,14 @@ deprecated: false
aliases: [] aliases: []
--- ---
* `{{split "tag1,tag2,tag3" "," }}` → ["tag1" "tag2" "tag3"] Examples:
```go-html-template
{{ split "tag1,tag2,tag3" "," }} → ["tag1", "tag2", "tag3"]
{{ split "abc" "" }} → ["a", "b", "c"]
```
{{% note %}}
`split` essentially does the opposite of [delimit]({{< ref "functions/delimit" >}}). While `split` creates a slice from a string, `delimit` creates a string from a slice.
{{% /note %}}

View file

@ -17,8 +17,6 @@ deprecated: false
aliases: [] aliases: []
--- ---
{{< new-in "0.74.0" >}}
If `SUBSTR` is an empty string, this function returns 1 plus the number of Unicode code points in `STRING`. If `SUBSTR` is an empty string, this function returns 1 plus the number of Unicode code points in `STRING`.
Example|Result Example|Result

View file

@ -1,6 +1,6 @@
--- ---
title: strings.HasSuffix title: strings.HasSuffix
description: Determine whether or not a given string ends with the provided trailing suffix string. description: Determine whether a given string ends with the provided trailing suffix string.
date: 2019-08-13 date: 2019-08-13
publishdate: 2019-08-13 publishdate: 2019-08-13
lastmod: 2019-08-13 lastmod: 2019-08-13

View file

@ -21,8 +21,3 @@ Example:
The above will print `[1 2 4]`. The above will print `[1 2 4]`.
Also see https://en.wikipedia.org/wiki/Symmetric_difference Also see https://en.wikipedia.org/wiki/Symmetric_difference

View file

@ -22,7 +22,7 @@ aliases: []
Note that `upper` can be applied in your templates in more than one way: Note that `upper` can be applied in your templates in more than one way:
``` ```go-html-template
{{ upper "BatMan" }} → "BATMAN" {{ upper "BatMan" }} → "BATMAN"
{{ "BatMan" | upper }} → "BATMAN" {{ "BatMan" | upper }} → "BATMAN"
``` ```

View file

@ -68,6 +68,4 @@ The preceding partial would then output to the rendered page as follows, assumin
</header> </header>
{{< /output >}} {{< /output >}}
[singletemplate]: /templates/single-page-templates/ [singletemplate]: /templates/single-page-templates/

Some files were not shown because too many files have changed in this diff Show more