diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-12-02 09:19:23 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-12-02 09:19:23 +0100 |
commit | ef518485cec947464509d290e6edb237c833c379 (patch) | |
tree | 32761983e311e4c3f8498d7dc385449ae627b386 /docs/content | |
parent | 83080df61104089789272b429d00fa1e2d658598 (diff) | |
parent | da16527896d3087585c5e758083ea498dcabc2c3 (diff) |
Merge commit 'da16527896d3087585c5e758083ea498dcabc2c3'
Diffstat (limited to 'docs/content')
28 files changed, 340 insertions, 142 deletions
diff --git a/docs/content/en/content-management/multilingual.md b/docs/content/en/content-management/multilingual.md index e1343144e..4e4eba46e 100644 --- a/docs/content/en/content-management/multilingual.md +++ b/docs/content/en/content-management/multilingual.md @@ -368,7 +368,7 @@ In case you need to pass a custom data: (`(dict "Count" numeric_value_only)` is The following localization examples assume your site's primary language is English, with translations to French and German. {{< code-toggle file="config" >}} -defaultContentLang = 'en' +defaultContentLanguage = 'en' [languages] [languages.en] @@ -568,7 +568,19 @@ If there is more than one language defined, the `LanguagePrefix` variable will e ## 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. +If you organize content with translations in the same directory: + +```text +hugo new post/test.en.md +hugo new post/test.de.md +``` + +If you organize content with translations in different directories: + +```text +hugo new content/en/post/test.md +hugo new content/de/post/test.md +``` [abslangurl]: /functions/abslangurl [config]: /getting-started/configuration/ diff --git a/docs/content/en/content-management/urls.md b/docs/content/en/content-management/urls.md index 70ec34ab2..6b12f3a2e 100644 --- a/docs/content/en/content-management/urls.md +++ b/docs/content/en/content-management/urls.md @@ -79,7 +79,7 @@ The following is a list of values that can be used in a `permalink` definition i : the content's section `:sections` -: 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. +: the content's sections hierarchy. 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. `:title` : the content's title diff --git a/docs/content/en/functions/abslangurl.md b/docs/content/en/functions/abslangurl.md index 11d540bde..2e1996f7e 100644 --- a/docs/content/en/functions/abslangurl.md +++ b/docs/content/en/functions/abslangurl.md @@ -55,6 +55,7 @@ With `baseURL = https://example.org/docs/` {{ 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. diff --git a/docs/content/en/functions/chomp.md b/docs/content/en/functions/chomp.md index c56505c2c..3e61c8db5 100644 --- a/docs/content/en/functions/chomp.md +++ b/docs/content/en/functions/chomp.md @@ -10,7 +10,9 @@ menu: docs: parent: "functions" keywords: [trim] -signature: ["chomp INPUT"] +signature: + - "chomp INPUT" + - "strings.Chomp INPUT" workson: [] hugoversion: relatedfuncs: [truncate] diff --git a/docs/content/en/functions/countrunes.md b/docs/content/en/functions/countrunes.md index 0acef095b..01ded4d6f 100644 --- a/docs/content/en/functions/countrunes.md +++ b/docs/content/en/functions/countrunes.md @@ -9,7 +9,9 @@ menu: docs: parent: "functions" keywords: [counting, word count] -signature: ["countrunes INPUT"] +signature: + - "countrunes INPUT" + - "strings.CountRunes INPUT" workson: [] hugoversion: relatedfuncs: [] diff --git a/docs/content/en/functions/crypto.FNV32a.md b/docs/content/en/functions/crypto.FNV32a.md new file mode 100644 index 000000000..dddf7a9aa --- /dev/null +++ b/docs/content/en/functions/crypto.FNV32a.md @@ -0,0 +1,15 @@ +--- +title: crypto.FNV32a +description: Returns the FNV (Fowler–Noll–Vo) 32 bit hash of a given string. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [crypto hash FNV32 Fowler-Noll-Vo] +signature: ["crypto.FNV32a STRING"] +aliases: [] +--- + +This function calculates the 32 bit [FNV1a hash](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash) of a given string according to the [specification](https://datatracker.ietf.org/doc/html/draft-eastlake-fnv-12): + + {{ crypto.FNV32a "Hello world" }} → 1498229191 diff --git a/docs/content/en/functions/dateformat.md b/docs/content/en/functions/dateformat.md index 7a16e80b2..210913b87 100644 --- a/docs/content/en/functions/dateformat.md +++ b/docs/content/en/functions/dateformat.md @@ -9,7 +9,9 @@ menu: docs: parent: "functions" keywords: [dates,time,strings] -signature: ["time.Format LAYOUT INPUT"] +signature: + - "time.Format LAYOUT INPUT" + - "dateFormat LAYOUT INPUT" workson: [] hugoversion: relatedfuncs: [Format,now,Unix,time] diff --git a/docs/content/en/functions/duration.md b/docs/content/en/functions/duration.md new file mode 100644 index 000000000..bf771c0a9 --- /dev/null +++ b/docs/content/en/functions/duration.md @@ -0,0 +1,32 @@ +--- +title: duration +description: Returns a `time.Duration` structure, using the given time unit and duration number. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [time duration] +signature: ["duration TIME_UNIT DURATION_NUMBER"] +aliases: [] +--- + +`time.Duration` converts a given number into a [`time.Duration`](https://pkg.go.dev/time#Duration) structure so you can access its fields. E.g. you can perform [time operations](https://pkg.go.dev/time#Duration) on the returned `time.Duration` value: + + {{ printf "There are %.0f seconds in one day." (duration "hour" 24).Seconds }} + <!-- Output: There are 86400 seconds in one day. --> + +Make your code simpler to understand by using a [chained pipeline](https://pkg.go.dev/text/template#hdr-Pipelines): + + {{ mul 7.75 60 | duration "minute" }} → 7h45m0s + {{ mul 120 60 | mul 1000 | duration "millisecond" }} → 2h0m0s + +You have to specify a time unit for the number given to the function. Valid time units are: + +Duration|Valid time units +:--|:-- +hours|`hour`, `h` +minutes|`minute`, `m` +seconds|`second`, `s` +milliseconds|`millisecond`, `ms` +microseconds|`microsecond`, `us`, `µs` +nanoseconds|`nanosecond`, `ns` diff --git a/docs/content/en/functions/emojify.md b/docs/content/en/functions/emojify.md index 20e30fafa..a323470b7 100644 --- a/docs/content/en/functions/emojify.md +++ b/docs/content/en/functions/emojify.md @@ -16,7 +16,7 @@ relatedfuncs: [] deprecated: false --- -`emoji` runs a passed string through the Emoji emoticons processor. +`emojify` runs a passed string through the Emoji emoticons processor. See the [Emoji cheat sheet][emojis] for available emoticons. diff --git a/docs/content/en/functions/findRe.md b/docs/content/en/functions/findRe.md index 2896e3cd1..8e08bfc0d 100644 --- a/docs/content/en/functions/findRe.md +++ b/docs/content/en/functions/findRe.md @@ -12,7 +12,7 @@ signature: relatedfuncs: [replaceRE] aliases: [] --- -By default, the `findRE` function finds all matches. You can limit the number of matches with an optional LIMIT paramater. +By default, the `findRE` function finds all matches. You can limit the number of matches with an optional LIMIT 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. diff --git a/docs/content/en/functions/i18n.md b/docs/content/en/functions/i18n.md index 34a6ff022..8f8c9642c 100644 --- a/docs/content/en/functions/i18n.md +++ b/docs/content/en/functions/i18n.md @@ -10,7 +10,10 @@ menu: docs: parent: "functions" keywords: [internationalization,i18n,multilingual] -signature: ["i18n KEY", "T KEY"] +signature: + - "i18n KEY" + - "T KEY" + - "lang.Translate KEY" workson: [] hugoversion: relatedfuncs: [] diff --git a/docs/content/en/functions/lower.md b/docs/content/en/functions/lower.md index 0e8ba6c6d..3fbfc919b 100644 --- a/docs/content/en/functions/lower.md +++ b/docs/content/en/functions/lower.md @@ -10,7 +10,9 @@ menu: docs: parent: "functions" keywords: [strings,casing] -signature: ["lower INPUT"] +signature: + - "lower INPUT" + - "strings.ToLower INPUT" workson: [] hugoversion: relatedfuncs: [] @@ -18,6 +20,10 @@ deprecated: false aliases: [] --- -``` -{{lower "BatMan"}} → "batman" + +Note that `lower` can be applied in your templates in more than one way: + +```go-html-template +{{ lower "BatMan" }} → "batman" +{{ "BatMan" | lower }} → "batman" ``` diff --git a/docs/content/en/functions/replace.md b/docs/content/en/functions/replace.md index 07b83d035..36e392015 100644 --- a/docs/content/en/functions/replace.md +++ b/docs/content/en/functions/replace.md @@ -8,11 +8,13 @@ categories: [functions] menu: docs: parent: "functions" -keywords: [] -signature: ["strings.Replace INPUT OLD NEW [LIMIT]", "replace INPUT OLD NEW [LIMIT]"] +keywords: [replace] +signature: + - "replace INPUT OLD NEW [LIMIT]" + - "strings.Replace INPUT OLD NEW [LIMIT]" workson: [] hugoversion: -relatedfuncs: [] +relatedfuncs: [replaceRE] deprecated: false aliases: [] --- diff --git a/docs/content/en/functions/replacere.md b/docs/content/en/functions/replacere.md index f1e34ba65..cc4eb5dc2 100644 --- a/docs/content/en/functions/replacere.md +++ b/docs/content/en/functions/replacere.md @@ -5,14 +5,14 @@ categories: [functions] menu: docs: parent: functions -keywords: [regex] +keywords: [replace regex] signature: - "replaceRE PATTERN REPLACEMENT INPUT [LIMIT]" - "strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]" -relatedfuncs: [findRE] +relatedfuncs: [replace,findRE] aliases: [] --- -By default, the `replaceRE` function replaces all matches. You can limit the number of matches with an optional LIMIT paramater. +By default, the `replaceRE` function replaces all matches. You can limit the number of matches with an optional LIMIT 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. diff --git a/docs/content/en/functions/slicestr.md b/docs/content/en/functions/slicestr.md index 254ad9a61..8164f2720 100644 --- a/docs/content/en/functions/slicestr.md +++ b/docs/content/en/functions/slicestr.md @@ -10,7 +10,9 @@ menu: docs: parent: "functions" keywords: [strings] -signature: ["slicestr STRING START [END]"] +signature: + - "slicestr STRING START [END]" + - "strings.SliceString STRING START [END]" workson: [] hugoversion: relatedfuncs: [] diff --git a/docs/content/en/functions/strings.Contains.md b/docs/content/en/functions/strings.Contains.md new file mode 100644 index 000000000..8ebd9ad33 --- /dev/null +++ b/docs/content/en/functions/strings.Contains.md @@ -0,0 +1,18 @@ +--- +title: strings.Contains +description: Reports whether a string contains a substring. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [string strings substring contains] +signature: ["strings.Contains STRING SUBSTRING"] +aliases: [] +relatedfuncs: [strings.ContainsAny] +--- + + {{ strings.Contains "Hugo" "go" }} → true + +The check is case sensitive: + + {{ strings.Contains "Hugo" "Go" }} → false diff --git a/docs/content/en/functions/strings.ContainsAny.md b/docs/content/en/functions/strings.ContainsAny.md new file mode 100644 index 000000000..bfbc2242b --- /dev/null +++ b/docs/content/en/functions/strings.ContainsAny.md @@ -0,0 +1,18 @@ +--- +title: strings.ContainsAny +description: Reports whether a string contains any character from a given string. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [string strings substring contains any] +signature: ["strings.ContainsAny STRING CHARACTERS"] +aliases: [] +relatedfuncs: [strings.Contains] +--- + + {{ strings.ContainsAny "Hugo" "gm" }} → true + +The check is case sensitive: + + {{ strings.ContainsAny "Hugo" "Gm" }} → false diff --git a/docs/content/en/functions/strings.FirstUpper.md b/docs/content/en/functions/strings.FirstUpper.md new file mode 100644 index 000000000..b97d00f29 --- /dev/null +++ b/docs/content/en/functions/strings.FirstUpper.md @@ -0,0 +1,14 @@ +--- +title: strings.FirstUpper +description: Capitalizes the first character of a given string. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [strings capitalize uppercase first] +signature: ["strings.FirstUpper STRING"] +hugoversion: +aliases: [] +--- + + {{ strings.FirstUpper "foo" }} → "Foo" diff --git a/docs/content/en/functions/substr.md b/docs/content/en/functions/substr.md index 31f733e0b..4a00b6eb1 100644 --- a/docs/content/en/functions/substr.md +++ b/docs/content/en/functions/substr.md @@ -11,7 +11,9 @@ menu: parent: "functions" keywords: [strings] aliases: [] -signature: ["substr STRING START [LENGTH]"] +signature: + - "substr STRING START [LENGTH]" + - "strings.Substr STRING START [LENGTH]" workson: [] hugoversion: relatedfuncs: [] diff --git a/docs/content/en/functions/time.ParseDuration.md b/docs/content/en/functions/time.ParseDuration.md new file mode 100644 index 000000000..aabba601a --- /dev/null +++ b/docs/content/en/functions/time.ParseDuration.md @@ -0,0 +1,20 @@ +--- +title: time.ParseDuration +description: Parses a given duration string into a `time.Duration` structure. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [time parse duration] +signature: ["time.ParseDuration DURATION"] +hugoversion: +aliases: [] +--- + +`time.ParseDuration` parses a duration string into a [`time.Duration`](https://pkg.go.dev/time#Duration) structure so you can access its fields. +A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as `300ms`, `-1.5h` or `2h45m`. Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. + +You can perform [time operations](https://pkg.go.dev/time#Duration) on the returned `time.Duration` value: + + {{ printf "There are %.0f seconds in one day." (time.ParseDuration "24h").Seconds }} + <!-- Output: There are 86400 seconds in one day. --> diff --git a/docs/content/en/functions/title.md b/docs/content/en/functions/title.md index 201e4c140..6c87d69ac 100644 --- a/docs/content/en/functions/title.md +++ b/docs/content/en/functions/title.md @@ -10,7 +10,9 @@ menu: docs: parent: "functions" keywords: [strings] -signature: ["title INPUT"] +signature: + - "title INPUT" + - "strings.Title INPUT" workson: [] hugoversion: relatedfuncs: [] diff --git a/docs/content/en/functions/trim.md b/docs/content/en/functions/trim.md index 7945ffef9..fec435ec7 100644 --- a/docs/content/en/functions/trim.md +++ b/docs/content/en/functions/trim.md @@ -10,7 +10,9 @@ menu: docs: parent: "functions" keywords: [strings] -signature: ["trim INPUT CUTSET"] +signature: + - "trim INPUT CUTSET" + - "strings.Trim INPUT CUTSET" workson: [] hugoversion: relatedfuncs: [] diff --git a/docs/content/en/functions/truncate.md b/docs/content/en/functions/truncate.md index 8d0dd36b1..54cfb3612 100644 --- a/docs/content/en/functions/truncate.md +++ b/docs/content/en/functions/truncate.md @@ -10,7 +10,9 @@ menu: docs: parent: "functions" keywords: [strings] -signature: ["truncate SIZE INPUT", "truncate SIZE ELLIPSIS INPUT"] +signature: + - "truncate SIZE [ELLIPSIS] INPUT" + - "strings.Truncate SIZE [ELLIPSIS] INPUT" workson: [] hugoversion: 19 relatedfuncs: [] diff --git a/docs/content/en/functions/upper.md b/docs/content/en/functions/upper.md index c7d523217..02f4cd578 100644 --- a/docs/content/en/functions/upper.md +++ b/docs/content/en/functions/upper.md @@ -11,7 +11,9 @@ menu: docs: parent: "functions" toc: -signature: ["upper INPUT"] +signature: + - "upper INPUT" + - "strings.ToUpper INPUT" workson: [] hugoversion: relatedfuncs: [] diff --git a/docs/content/en/getting-started/directory-structure.md b/docs/content/en/getting-started/directory-structure.md index 05c1f55f3..d9f163498 100644 --- a/docs/content/en/getting-started/directory-structure.md +++ b/docs/content/en/getting-started/directory-structure.md @@ -20,18 +20,20 @@ toc: true {{< youtube sB0HLHjgQ7E >}} -Running the `hugo new site` generator from the command-line will create a directory structure with the following elements: +Running `hugo new site example` from the command line creates a directory structure with the following elements: ```txt -. -├── archetypes -├── config.toml -├── content -├── data -├── layouts -├── public -├── static -└── themes +example/ +├── archetypes/ +│ └── default.md +├── assets/ +├── content/ +├── data/ +├── layouts/ +├── public/ +├── static/ +├── themes/ +└── config.toml ``` ## Directory Structure Explained @@ -43,7 +45,7 @@ The following is a high-level overview of each of the directories with links to By default, Hugo will create new content files with at least `date`, `title` (inferred from the filename), and `draft = true`. This saves time and promotes consistency for sites using multiple content types. You can create your own [archetypes][] with custom preconfigured front matter fields as well. [`assets`][] -: Stores all the files which need be processed by [Hugo Pipes](/hugo-pipes/). Only the files whose `.Permalink` or `.RelPermalink` are used will be published to the `public` directory. Note: assets directory is not created by default. +: Stores all the files which need be processed by [Hugo Pipes](/hugo-pipes/). Only the files whose `.Permalink` or `.RelPermalink` are used will be published to the `public` directory. [`config`](/getting-started/configuration/) : Hugo ships with a large number of [configuration directives][]. diff --git a/docs/content/en/getting-started/quick-start.md b/docs/content/en/getting-started/quick-start.md index 4fbdb1c8f..829800048 100644 --- a/docs/content/en/getting-started/quick-start.md +++ b/docs/content/en/getting-started/quick-start.md @@ -1,176 +1,216 @@ --- title: Quick Start linktitle: Quick Start -description: Create a Hugo site using the beautiful Ananke theme. -date: 2013-07-01 -publishdate: 2013-07-01 +description: Learn to create a Hugo site in minutes. categories: [getting started] keywords: [quick start,usage] -authors: [Shekhar Gulati, Ryan Watters] menu: docs: - parent: "getting-started" + parent: getting-started weight: 10 weight: 10 -sections_weight: 10 -draft: false -aliases: [/quickstart/,/overview/quickstart/] toc: true +aliases: [/quickstart/,/overview/quickstart/] --- -{{% note %}} -This quick start uses `macOS` in the examples. For instructions about how to install Hugo on other operating systems, see [install](/installation/). +In this tutorial you will: -It is required to have [Git installed](https://git-scm.com/downloads) to run this tutorial. +1. Create a site +2. Add content +3. Configure the site +4. Publish the site -For other approaches to learning Hugo (like books or video tutorials), refer to the [external learning resources](/getting-started/external-learning-resources/) page. -{{% /note %}} +## Prerequisites -## Step 1: Install Hugo +Before you begin this tutorial you must: -Install the **extended version of Hugo** (this is required for the current theme used). +1. [Install Hugo] (the extended edition) +1. [Install Git] -{{% note %}} -`Homebrew` and `MacPorts`, package managers for `macOS`, can be installed from [brew.sh](https://brew.sh/) or [macports.org](https://www.macports.org/) respectively. See [install](/installation/) if you are running Windows etc. -{{% /note %}} +You must also be comfortable working from the command line. -```bash -brew install hugo -# or -port install hugo -``` +## Create a site + +### Commands + +Run these commands[^1] to create a Hugo site with the [Ananke] theme. The next section provides an explanation of each command. -To verify your new install: +[^1]: If you are a Windows user, you must run these commands with [PowerShell]. |