mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-25 07:48:52 +00:00
Markdown linting and cleanup
This commit is contained in:
@@ -123,7 +123,7 @@ toc: true
|
||||
[Mathematics]: /content-management/mathematics/
|
||||
[Menus]: /content-management/menus/
|
||||
[Minification]: /getting-started/configuration/#configure-minify
|
||||
[Modules]: https://gohugo.io/hugo-modules/
|
||||
[Modules]: /hugo-modules/
|
||||
[Multilingual]: /content-management/multilingual/
|
||||
[Multiplatform]: /installation/
|
||||
[Output formats]: /templates/output-formats/
|
||||
@@ -134,6 +134,6 @@ toc: true
|
||||
[Syntax highlighting]: /content-management/syntax-highlighting/
|
||||
[Tailwind CSS processing]: /functions/css/tailwindcss/
|
||||
[Taxonomies]: /content-management/taxonomies/
|
||||
[Templates]: templates/introduction/
|
||||
[Templates]: /templates/introduction/
|
||||
[Themes]: https://themes.gohugo.io/
|
||||
[URL management]: /content-management/urls/
|
||||
|
||||
@@ -21,7 +21,6 @@ publishResources = true
|
||||
render = 'always'
|
||||
{{< /code-toggle >}}
|
||||
|
||||
|
||||
list
|
||||
: When to include the page within page collections. Specify one of:
|
||||
|
||||
@@ -115,7 +114,7 @@ public/
|
||||
In the example above, note that:
|
||||
|
||||
1. Hugo did not publish an HTML file for the page.
|
||||
2. Despite setting `publishResources` to `false` in front matter, Hugo published the [page resources] because we invoked the [`RelPermalink`] method on each resource. This is the expected behavior.
|
||||
1. Despite setting `publishResources` to `false` in front matter, Hugo published the [page resources] because we invoked the [`RelPermalink`] method on each resource. This is the expected behavior.
|
||||
|
||||
## Example -- headless section
|
||||
|
||||
@@ -181,7 +180,7 @@ public/
|
||||
In the example above, note that:
|
||||
|
||||
1. Hugo did not publish an HTML file for the page.
|
||||
2. Despite setting `publishResources` to `false` in front matter, Hugo correctly published the [page resources] because we invoked the [`RelPermalink`] method on each resource. This is the expected behavior.
|
||||
1. Despite setting `publishResources` to `false` in front matter, Hugo correctly published the [page resources] because we invoked the [`RelPermalink`] method on each resource. This is the expected behavior.
|
||||
|
||||
## Example -- list without publishing
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ toc: true
|
||||
|
||||
A content adapter is a template that dynamically creates pages when building a site. For example, use a content adapter to create pages from a remote data source such as JSON, TOML, YAML, or XML.
|
||||
|
||||
Unlike templates that reside in the `layouts` directory, content adapters reside in the `content` directory, no more than one per directory per language. When a content adapter creates a page, the page's [logical path](g)will be relative to the content adapter.
|
||||
Unlike templates that reside in the `layouts` directory, content adapters reside in the `content` directory, no more than one per directory per language. When a content adapter creates a page, the page's [logical path](g) will be relative to the content adapter.
|
||||
|
||||
```text
|
||||
content/
|
||||
@@ -280,7 +280,7 @@ Step 4
|
||||
With multilingual sites you can:
|
||||
|
||||
1. Create one content adapter for all languages using the [`EnableAllLanguages`](#enablealllanguages) method as described above.
|
||||
2. Create content adapters unique to each language. See the examples below.
|
||||
1. Create content adapters unique to each language. See the examples below.
|
||||
|
||||
### Translations by file name
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ Hugo provides custom Markdown features including:
|
||||
[Goldmark]: https://github.com/yuin/goldmark
|
||||
[Markdown]: https://daringfireball.net/projects/markdown/
|
||||
[Mathematics]: /content-management/mathematics/
|
||||
[Render hooks]: https://gohugo.io/render-hooks/introduction/
|
||||
[Render hooks]: /render-hooks/introduction/
|
||||
[configure goldmark]: /getting-started/configuration-markup/#goldmark
|
||||
|
||||
### HTML
|
||||
@@ -101,7 +101,6 @@ hugo --logLevel info
|
||||
[configure the AsciiDoc renderer]: /getting-started/configuration-markup/#asciidoc
|
||||
[configure asciidoc]: /getting-started/configuration-markup/#asciidoc
|
||||
|
||||
|
||||
### Pandoc
|
||||
|
||||
Create your content in the [Pandoc] format preceded by front matter. Hugo renders Pandoc content to HTML using the Pandoc executable. You must install Pandoc to use the Pandoc content format.
|
||||
|
||||
@@ -74,7 +74,6 @@ The field names below are reserved. For example, you cannot create a custom fiel
|
||||
|
||||
(`string`) The date associated with the page, typically the creation date. Note that the TOML format also supports unquoted date/time values. See the [dates](#dates) section for examples. Access this value from a template using the [`Date`] method on a `Page` object.
|
||||
|
||||
|
||||
[`date`]: /methods/page/date/
|
||||
|
||||
###### description
|
||||
@@ -144,7 +143,7 @@ lang
|
||||
|
||||
[`layout`]: /methods/page/layout/
|
||||
[template lookup order]: /templates/lookup-order/
|
||||
[target a specific template]: templates/lookup-order/#target-a-template
|
||||
[target a specific template]: /templates/lookup-order/#target-a-template
|
||||
|
||||
###### linkTitle
|
||||
|
||||
@@ -442,5 +441,5 @@ When populating a date field, whether a [custom page parameter](#parameters) or
|
||||
To override the default time zone, set the [`timeZone`](https://gohugo.io/getting-started/configuration/#timezone) in your site configuration. The order of precedence for determining the time zone is:
|
||||
|
||||
1. The time zone offset in the date/time string
|
||||
2. The time zone specified in your site configuration
|
||||
3. The `Etc/UTC` time zone
|
||||
1. The time zone specified in your site configuration
|
||||
1. The `Etc/UTC` time zone
|
||||
|
||||
@@ -500,15 +500,14 @@ If you change image processing methods or options, or if you rename or remove im
|
||||
hugo --gc
|
||||
```
|
||||
|
||||
|
||||
[`anchor`]: /content-management/image-processing#anchor
|
||||
[mounted]: /hugo-modules/configuration#module-configuration-mounts
|
||||
[page bundle]: /content-management/page-bundles/
|
||||
[`lang.FormatNumber`]: /functions/lang/formatnumber/
|
||||
[filters]: /functions/images/filter/#image-filters
|
||||
[github.com/disintegration/imaging]: <https://github.com/disintegration/imaging#image-resizing>
|
||||
[Smartcrop]: <https://github.com/muesli/smartcrop#smartcrop>
|
||||
[Exif]: <https://en.wikipedia.org/wiki/Exif>
|
||||
[github.com/disintegration/imaging]: https://github.com/disintegration/imaging#image-resizing
|
||||
[Smartcrop]: https://github.com/muesli/smartcrop#smartcrop
|
||||
[Exif]: https://en.wikipedia.org/wiki/Exif
|
||||
[`Process`]: #process
|
||||
[`Colors`]: #colors
|
||||
[`Crop`]: #crop
|
||||
|
||||
@@ -45,7 +45,6 @@ title = true # default is true
|
||||
block = true # default is false
|
||||
{{< /code-toggle >}}
|
||||
|
||||
|
||||
## Standalone images
|
||||
|
||||
By default, when the [Goldmark] Markdown renderer encounters a standalone image element (no other elements or text on the same line), it wraps the image element within a paragraph element per the [CommonMark specification].
|
||||
|
||||
@@ -17,8 +17,8 @@ aliases: [/extras/menus/]
|
||||
To create a menu for your site:
|
||||
|
||||
1. Define the menu entries
|
||||
2. [Localize] each entry
|
||||
3. Render the menu with a [template]
|
||||
1. [Localize] each entry
|
||||
1. Render the menu with a [template]
|
||||
|
||||
Create multiple menus, either flat or nested. For example, create a main menu for the header, and a separate menu for the footer.
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ This is the default language configuration:
|
||||
|
||||
In the above, `en` is the language key.
|
||||
|
||||
|
||||
Language keys must conform to the syntax described in [RFC 5646]. For example:
|
||||
|
||||
- `en`
|
||||
@@ -165,7 +164,6 @@ Note that you cannot disable the default content language.
|
||||
|
||||
### Configure multilingual multihost
|
||||
|
||||
|
||||
Hugo supports multiple languages in a multihost configuration. This means you can configure a `baseURL` per `language`.
|
||||
|
||||
{{% note %}}
|
||||
@@ -217,7 +215,7 @@ There are two ways to manage your content translations. Both ensure each page is
|
||||
Considering the following example:
|
||||
|
||||
1. `/content/about.en.md`
|
||||
2. `/content/about.fr.md`
|
||||
1. `/content/about.fr.md`
|
||||
|
||||
The first file is assigned the English language and is linked to the second.
|
||||
The second file is assigned the French language and is linked to the first.
|
||||
@@ -251,7 +249,7 @@ The value of `contentDir` can be any valid path -- even absolute path references
|
||||
Considering the following example in conjunction with the configuration above:
|
||||
|
||||
1. `/content/english/about.md`
|
||||
2. `/content/french/about.md`
|
||||
1. `/content/french/about.md`
|
||||
|
||||
The first file is assigned the English language and is linked to the second.
|
||||
The second file is assigned the French language and is linked to the first.
|
||||
@@ -267,8 +265,8 @@ Any pages sharing the same `translationKey` set in front matter will be linked a
|
||||
Considering the following example:
|
||||
|
||||
1. `/content/about-us.en.md`
|
||||
2. `/content/om.nn.md`
|
||||
3. `/content/presentation/a-propos.fr.md`
|
||||
1. `/content/om.nn.md`
|
||||
1. `/content/presentation/a-propos.fr.md`
|
||||
|
||||
{{< code-toggle >}}
|
||||
translationKey: "about"
|
||||
|
||||
@@ -128,7 +128,6 @@ title ="Bar"
|
||||
url = "/:sections[last]/:slug"
|
||||
{{< /code-toggle >}}
|
||||
|
||||
|
||||
## Site configuration
|
||||
|
||||
### Permalinks
|
||||
|
||||
@@ -37,7 +37,7 @@ For a complete guide to contributing to Hugo, see the [Contribution Guide].
|
||||
[contributing]: CONTRIBUTING.md
|
||||
[create a proposal]: https://github.com/gohugoio/hugo/issues/new?labels=Proposal%2C+NeedsTriage&template=feature_request.md
|
||||
[documentation repository]: https://github.com/gohugoio/hugoDocs
|
||||
[documentation]: https://gohugo.io/documentation
|
||||
[documentation]: /documentation
|
||||
[forum]: https://discourse.gohugo.io
|
||||
[issue queue]: https://github.com/gohugoio/hugo/issues
|
||||
[themes]: https://themes.gohugo.io/
|
||||
|
||||
@@ -16,7 +16,7 @@ Visit [themes.gohugo.io] to browse a collection of themes created by the Hugo co
|
||||
To submit your theme:
|
||||
|
||||
1. Read the [submission guidelines]
|
||||
2. Open a pull request in the [themes repository]
|
||||
1. Open a pull request in the [themes repository]
|
||||
|
||||
Other useful theme directories:
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ The template above is rendered to:
|
||||
You can use `after` in combination with the [`first`] function and Hugo's [powerful sorting methods](/quick-reference/page-collections/#sort). Let's assume you have a `section` page at `example.com/articles`. You have 10 articles, but you want your template to show only two rows:
|
||||
|
||||
1. The top row is titled "Featured" and shows only the most recently published article (i.e. by `publishdate` in the content files' front matter).
|
||||
2. The second row is titled "Recent Articles" and shows only the 2nd- to 4th-most recently published articles.
|
||||
1. The second row is titled "Recent Articles" and shows only the 2nd- to 4th-most recently published articles.
|
||||
|
||||
{{< code file=layouts/section/articles.html >}}
|
||||
{{ define "main" }}
|
||||
|
||||
@@ -33,7 +33,6 @@ To create an empty map:
|
||||
{{ $m := dict }}
|
||||
```
|
||||
|
||||
|
||||
Note that the `key` can be either a `string` or a `string slice`. The latter is useful to create a deeply nested structure, e.g.:
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -384,8 +384,8 @@ Is rendered to:
|
||||
To exclude a page with an undefined field from a boolean _inequality_ test:
|
||||
|
||||
1. Create a collection using a boolean comparison
|
||||
2. Create a collection using a nil comparison
|
||||
3. Subtract the second collection from the first collection using the [`collections.Complement`] function.
|
||||
1. Create a collection using a nil comparison
|
||||
1. Subtract the second collection from the first collection using the [`collections.Complement`] function.
|
||||
|
||||
[`collections.Complement`]: /functions/collections/complement/
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ Use the [`warnidf`] function to allow optional suppression of specific warnings.
|
||||
|
||||
To prevent suppression of duplicate messages when using `warnf` for debugging, make each message unique with the [`math.Counter`] function. For example:
|
||||
|
||||
|
||||
```go-html-template
|
||||
{{ range site.RegularPages }}
|
||||
{{ .Section | warnf "%#[2]v [%[1]d]" math.Counter }}
|
||||
|
||||
@@ -117,11 +117,10 @@ This example uses the default dithering options.
|
||||
Regardless of dithering method, do both of the following to obtain the best results:
|
||||
|
||||
1. Scale the image _before_ dithering
|
||||
2. Output the image to a lossless format such as GIF or PNG
|
||||
1. Output the image to a lossless format such as GIF or PNG
|
||||
|
||||
The example below does both of these, and it sets the dithering palette to the three most dominant colors in the image.
|
||||
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "original.jpg" }}
|
||||
{{ $opts := dict
|
||||
@@ -157,6 +156,6 @@ For best results, if the dithering palette is grayscale, convert the image to gr
|
||||
The example above:
|
||||
|
||||
1. Resizes the image to be 800 px wide
|
||||
2. Converts the image to grayscale
|
||||
3. Dithers the image using the default (`FloydSteinberg`) dithering method with a grayscale palette
|
||||
4. Converts the image to the PNG format
|
||||
1. Converts the image to grayscale
|
||||
1. Dithers the image using the default (`FloydSteinberg`) dithering method with a grayscale palette
|
||||
1. Converts the image to the PNG format
|
||||
|
||||
@@ -72,7 +72,6 @@ hint
|
||||
|
||||
[`cwebp`]: https://developers.google.com/speed/webp/docs/cwebp
|
||||
|
||||
|
||||
```go-html-template
|
||||
{{ $filter := images.Process "webp" "icon" }}
|
||||
{{ $filter := images.Process "crop 200x200 center r90 webp q50 icon" }}
|
||||
|
||||
@@ -32,12 +32,10 @@ The Batch `ID` is used to create the base directory for this batch. Forward slas
|
||||
* [Config]
|
||||
* [SetOptions]
|
||||
|
||||
|
||||
## Group
|
||||
|
||||
The `Group` method take an `ID` (`string`) as argument. No slashes. It returns an object with these methods:
|
||||
|
||||
|
||||
#### Script
|
||||
|
||||
The `Script` method takes an `ID` (`string`) as argument. No slashes. It returns an [OptionsSetter] that can be used to set [script options] for this script.
|
||||
@@ -70,7 +68,6 @@ The `Instance` method takes two `string` arguments `SCRIPT_ID` and `INSTANCE_ID`
|
||||
|
||||
`SetOptions` takes a [params options] map. The instance options will be passed to any [runner] script in the same group, as JSON.
|
||||
|
||||
|
||||
#### Runner
|
||||
|
||||
The `Runner` method takes an `ID` (`string`) as argument. No slashes. It returns an [OptionsSetter] that can be used to set [script options] for this runner.
|
||||
@@ -129,7 +126,6 @@ The runner script's export must be a function that takes one argument, the group
|
||||
|
||||
Below is an example of a runner script that uses React to render elements. Note that the export (`default`) must match the `export` option in the [script options] (`default` is the default value for runner scripts) (runnable versions of examples on this page can be found at [js.Batch Demo Repo]):
|
||||
|
||||
|
||||
```js
|
||||
import * as ReactDOM from 'react-dom/client';
|
||||
import * as React from 'react';
|
||||
@@ -154,13 +150,11 @@ export default function Run(group) {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Config
|
||||
|
||||
Returns an [OptionsSetter] that can be used to set [build options] for the batch.
|
||||
|
||||
These are mostly the same as for [js.Build], but note that:
|
||||
These are mostly the same as for `js.Build`, but note that:
|
||||
|
||||
* `targetPath` is set automatically (there may be multiple outputs).
|
||||
* `format` must be `esm`, currently the only format supporting [code splitting].
|
||||
@@ -283,7 +277,6 @@ See [this discussion](https://discourse.gohugo.io/t/js-batch-with-simple-global-
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
|
||||
## Known Issues
|
||||
|
||||
In the official documentation for [ESBuild's code splitting], there's a warning note in the header. The two issues are:
|
||||
@@ -294,7 +287,7 @@ In the official documentation for [ESBuild's code splitting], there's a warning
|
||||
We have not seen the ordering issue as a problem during our [extensive testing](https://github.com/bep/hugojsbatchdemo) of this new feature with different libraries. There are two main cases:
|
||||
|
||||
1. Undefined execution order of imports, see [this comment](https://github.com/evanw/esbuild/issues/399#issuecomment-1458680887)
|
||||
2. Only one execution order of imports, see [this comment](https://github.com/evanw/esbuild/issues/399#issuecomment-735355932)
|
||||
1. Only one execution order of imports, see [this comment](https://github.com/evanw/esbuild/issues/399#issuecomment-735355932)
|
||||
|
||||
Many would say that both of the above are [code smells](https://en.wikipedia.org/wiki/Code_smell). The first one has a simple workaround in Hugo. Define the import order in its own script and make sure it gets passed early to ESBuild, e.g. by putting it in a script group with a name that comes early in the alphabet.
|
||||
|
||||
@@ -307,7 +300,7 @@ console.log('entrypoints-workaround.js');
|
||||
```
|
||||
|
||||
[build options]: #build-options
|
||||
[`Resource`]: https://gohugo.io/methods/resource/
|
||||
[`Resource`]: /methods/resource/
|
||||
[`Resources`]: /methods/page/resources/
|
||||
[`Resources.Mount`]: /methods/page/resources/#mount
|
||||
[`templates.Defer`]: /functions/templates/defer/
|
||||
@@ -319,13 +312,12 @@ console.log('entrypoints-workaround.js');
|
||||
[instance]: #instance
|
||||
[JavaScript import]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
|
||||
[js.Batch Demo Repo]: https://github.com/bep/hugojsbatchdemo/
|
||||
[js.Build]: https://gohugo.io/hugo-pipes/js/#options
|
||||
[map]: https://gohugo.io/functions/collections/dictionary/
|
||||
[map]: /functions/collections/dictionary/
|
||||
[OptionsSetter]: #optionssetter
|
||||
[page bundles]: https://gohugo.io/content-management/page-bundles/
|
||||
[page bundles]: /content-management/page-bundles/
|
||||
[params options]: #params-options
|
||||
[runner]: #runner
|
||||
[script options]: #script-options
|
||||
[script]: #script
|
||||
[SetOptions]: #optionssetter
|
||||
[with]: https://gohugo.io/functions/go-template/with/
|
||||
[with]: /functions/go-template/with/
|
||||
|
||||
@@ -74,7 +74,6 @@ sourceMap
|
||||
sourcesContent {{< new-in 0.140.0 >}}
|
||||
: (`bool`) Whether to include the content of the source files in the source map. By default, this is `true`.
|
||||
|
||||
|
||||
JSX {{< new-in 0.124.0 >}}
|
||||
: (`string`) How to handle/transform JSX syntax. One of: `transform`, `preserve`, `automatic`. Default is `transform`. Notably, the `automatic` transform was introduced in React 17+ and will cause the necessary JSX helper functions to be imported automatically. See https://esbuild.github.io/api/#jsx
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ To list the GET and POST operations for each of the API paths:
|
||||
|
||||
Hugo renders this to:
|
||||
|
||||
|
||||
```html
|
||||
<p>/pets</p>
|
||||
<dl>
|
||||
|
||||
@@ -23,7 +23,6 @@ See Go's [`path.Join`] and [`path.Clean`] documentation for details.
|
||||
[`path.Clean`]: https://pkg.go.dev/path#Clean
|
||||
[`path.Join`]: https://pkg.go.dev/path#Join
|
||||
|
||||
|
||||
```go-html-template
|
||||
{{ path.Join "partial" "news.html" }} → partial/news.html
|
||||
{{ path.Join "partial/" "news.html" }} → partial/news.html
|
||||
|
||||
@@ -49,8 +49,8 @@ Place this in your baseof.html template:
|
||||
The example above:
|
||||
|
||||
1. Captures the template as a resource
|
||||
2. Executes the resource as a template, passing the current page in context
|
||||
3. Publishes the resource to css/main.css
|
||||
1. Executes the resource as a template, passing the current page in context
|
||||
1. Publishes the resource to css/main.css
|
||||
|
||||
The result is:
|
||||
|
||||
|
||||
@@ -36,6 +36,6 @@ The hash algorithm may be one of `md5`, `sha256` (default), `sha384`, or `sha512
|
||||
After cryptographically hashing the resource content:
|
||||
|
||||
1. The values returned by the `.Permalink` and `.RelPermalink` methods include the hash sum
|
||||
2. The resource's `.Data.Integrity` method returns a [Subresource Integrity] (SRI) value consisting of the name of the hash algorithm, one hyphen, and the base64-encoded hash sum
|
||||
1. The resource's `.Data.Integrity` method returns a [Subresource Integrity] (SRI) value consisting of the name of the hash algorithm, one hyphen, and the base64-encoded hash sum
|
||||
|
||||
[Subresource Integrity]: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
|
||||
|
||||
@@ -48,9 +48,9 @@ Place this in your baseof.html template:
|
||||
The example above:
|
||||
|
||||
1. Creates a map with the relevant key-value pairs using the [`dict`] function
|
||||
2. Encodes the map as a JSON string using the [`jsonify`] function
|
||||
3. Creates a resource from the JSON string using the `resources.FromString` function
|
||||
4. Publishes the file to the root of the `public` directory using the resource's `.Publish` method
|
||||
1. Encodes the map as a JSON string using the [`jsonify`] function
|
||||
1. Creates a resource from the JSON string using the `resources.FromString` function
|
||||
1. Publishes the file to the root of the `public` directory using the resource's `.Publish` method
|
||||
|
||||
Combine `resources.FromString` with [`resources.ExecuteAsTemplate`] if your string contains template actions. Rewriting the example above:
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ aliases: [/functions/safecss]
|
||||
Use the `safe.CSS` function to encapsulate known safe content that matches any of:
|
||||
|
||||
1. The CSS3 stylesheet production, such as `p { color: purple }`.
|
||||
2. The CSS3 rule production, such as `a[href=~"https:"].foo#bar`.
|
||||
3. CSS3 declaration productions, such as `color: red; margin: 2px`.
|
||||
4. The CSS3 value production, such as `rgba(0, 0, 255, 127)`.
|
||||
1. The CSS3 rule production, such as `a[href=~"https:"].foo#bar`.
|
||||
1. CSS3 declaration productions, such as `color: red; margin: 2px`.
|
||||
1. The CSS3 value production, such as `rgba(0, 0, 255, 127)`.
|
||||
|
||||
Use of this type presents a security risk: the encapsulated content should come from a trusted source, as it will be included verbatim in the template output.
|
||||
|
||||
|
||||
@@ -20,6 +20,6 @@ The START and END positions are zero-based, where `0` represents the first chara
|
||||
{{ slicestr "BatMan" 0 3 }} → Bat
|
||||
```
|
||||
|
||||
The START and END arguments represent the endpoints of a half-open [interval], a concept that may be difficult to grasp when first encountered. You may find that the [`strings.Substr`] function is easier to understand.
|
||||
The START and END arguments represent the endpoints of a half-open [interval](g), a concept that may be difficult to grasp when first encountered. You may find that the [`strings.Substr`] function is easier to understand.
|
||||
|
||||
[`strings.Substr`]: /functions/strings/substr/
|
||||
|
||||
@@ -46,7 +46,6 @@ In some rare use cases, you may need to defer the execution of a template until
|
||||
This function only works in combination with the `with` keyword.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
{{% note %}}
|
||||
Variables defined on the outside are not visible on the inside and vice versa. To pass in data, use the `data` [option](#options).
|
||||
{{% /note %}}
|
||||
@@ -79,7 +78,6 @@ key (`string`)
|
||||
data (`map`)
|
||||
: Optional map to pass as data to the deferred template. This will be available in the deferred template as `.` or `$`.
|
||||
|
||||
|
||||
```go-html-template
|
||||
Language Outside: {{ site.Language.Lang }}
|
||||
Page Outside: {{ .RelPermalink }}
|
||||
|
||||
@@ -42,13 +42,12 @@ The list of valid time zones may be system dependent, but should include `UTC`,
|
||||
The order of precedence for determining the time zone is:
|
||||
|
||||
1. The time zone offset in the date/time string
|
||||
2. The time zone provided as the second argument to the `time.AsTime` function
|
||||
3. The time zone specified in your site configuration
|
||||
4. The `Etc/UTC` time zone
|
||||
|
||||
1. The time zone provided as the second argument to the `time.AsTime` function
|
||||
1. The time zone specified in your site configuration
|
||||
1. The `Etc/UTC` time zone
|
||||
|
||||
[IANA Time Zone database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
[`time.Time`]: https://pkg.go.dev/time#Time
|
||||
[`timeZone`]: https://gohugo.io/getting-started/configuration/#timezone
|
||||
[`timeZone`]: /getting-started/configuration/#timezone
|
||||
[functions]: /functions/time/
|
||||
[methods]: /methods/time/
|
||||
|
||||
@@ -32,7 +32,6 @@ There are 86400 seconds in one day.
|
||||
|
||||
The time unit must be one of the following:
|
||||
|
||||
|
||||
Duration|Valid time units
|
||||
:--|:--
|
||||
hours|`hour`, `h`
|
||||
|
||||
@@ -37,10 +37,10 @@ Examples of parsable string representations:
|
||||
To override the default time zone, set the [`timeZone`] in your site configuration. The order of precedence for determining the time zone is:
|
||||
|
||||
1. The time zone offset in the date/time string
|
||||
2. The time zone specified in your site configuration
|
||||
3. The `Etc/UTC` time zone
|
||||
1. The time zone specified in your site configuration
|
||||
1. The `Etc/UTC` time zone
|
||||
|
||||
[`timeZone`]: https://gohugo.io/getting-started/configuration/#timezone
|
||||
[`timeZone`]: /getting-started/configuration/#timezone
|
||||
|
||||
## Layout string
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ To format and [localize](g) the value, pass it through the [`time.Format`] funct
|
||||
|
||||
The `time.Now` function returns a `time.Time` value, so you can chain any of the [time methods] to the resulting value. For example:
|
||||
|
||||
|
||||
```go-html-template
|
||||
{{ time.Now.Year }} → 2023 (int)
|
||||
{{ time.Now.Weekday.String }} → Sunday
|
||||
|
||||
@@ -17,7 +17,6 @@ aliases: [/functions/time.parseduration]
|
||||
|
||||
The `time.ParseDuration` function returns a time.Duration value that you can use with any of the `Duration` [methods].
|
||||
|
||||
|
||||
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`.
|
||||
|
||||
This template:
|
||||
|
||||
@@ -17,7 +17,6 @@ See the list of [emoji shortcodes] for available emoticons.
|
||||
|
||||
The `emojify` function can be called in your templates but not directly in your content files by default. For emojis in content files, set `enableEmoji` to `true` in your site's [configuration]. Then you can write emoji shorthand directly into your content files;
|
||||
|
||||
|
||||
```text
|
||||
I :heart: Hugo!
|
||||
```
|
||||
|
||||
@@ -32,7 +32,6 @@ See [Configure Cache Busters](#configure-cache-busters).
|
||||
|
||||
(`string`) When to use the cached resources in `/resources/_gen` for PostCSS and ToCSS. Valid values are `never`, `always` and `fallback`. The last value means that the cache will be tried if PostCSS/extended version is not available.
|
||||
|
||||
|
||||
## Configure cache busters
|
||||
|
||||
{{< new-in 0.112.0 >}}
|
||||
|
||||
@@ -107,7 +107,7 @@ Superscript|`1^st^`|`1<sup>st</sup>`
|
||||
To avoid a conflict when enabling the Hugo Goldmark Extras subscript extension, if you want to render subscript and strikethrough text concurrently you must:
|
||||
|
||||
1. Disable the Goldmark strikethrough extension
|
||||
2. Enable the Hugo Goldmark Extras delete extension
|
||||
1. Enable the Hugo Goldmark Extras delete extension
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ ID = 'G-XXXXXXXXX'
|
||||
Now consider the following scenario:
|
||||
|
||||
1. You don't want to load the analytics code when running `hugo server`.
|
||||
2. You want to use different Google tag IDs for your production and staging environments. For example:
|
||||
1. You want to use different Google tag IDs for your production and staging environments. For example:
|
||||
|
||||
- `G-PPPPPPPPP` for production
|
||||
- `G-SSSSSSSSS` for staging
|
||||
@@ -149,7 +149,7 @@ To satisfy these requirements, configure your site as follows:
|
||||
|
||||
By default, Hugo sets its `environment` to `development` when running `hugo server`. In the absence of a `config/development` directory, Hugo uses the `config/_default` directory.
|
||||
|
||||
2. `config/production/hugo.toml`
|
||||
1. `config/production/hugo.toml`
|
||||
|
||||
Include this section only:
|
||||
|
||||
@@ -162,7 +162,7 @@ To satisfy these requirements, configure your site as follows:
|
||||
|
||||
By default, Hugo sets its `environment` to `production` when running `hugo`. The analytics code will use the `G-PPPPPPPPP` tag ID.
|
||||
|
||||
3. `config/staging/hugo.toml`
|
||||
1. `config/staging/hugo.toml`
|
||||
|
||||
Include this section only:
|
||||
|
||||
@@ -609,7 +609,6 @@ These settings do not apply to the [`Next`] or [`Prev`] methods on a `Pages` obj
|
||||
|
||||
See [Configure Build](/getting-started/configuration-build/).
|
||||
|
||||
|
||||
## Configure server
|
||||
|
||||
This is only relevant when running `hugo server`, and it allows to set HTTP headers during development, which allows you to test out your Content Security Policy and similar. The configuration format matches [Netlify's](https://docs.netlify.com/routing/headers/#syntax-for-the-netlify-configuration-file) with slightly more powerful [Glob matching](https://github.com/gobwas/glob):
|
||||
@@ -698,7 +697,6 @@ to = '/en/404.html'
|
||||
status = 404
|
||||
{{< /code-toggle >}}
|
||||
|
||||
|
||||
## Configure title case
|
||||
|
||||
By default, Hugo follows the capitalization rules published in the [Associated Press Stylebook] when creating automatic section titles, and when transforming strings with the [`strings.Title`] function.
|
||||
@@ -890,7 +888,6 @@ If you want to know the current value of `cacheDir`, you can run `hugo config`,
|
||||
[templates]: /templates/
|
||||
[static-files]: /content-management/static-files/
|
||||
|
||||
|
||||
## Configure HTTP cache
|
||||
|
||||
{{< new-in 0.127.0 >}}
|
||||
|
||||
@@ -25,14 +25,12 @@ Publication date: March 2022\
|
||||
Length: 488 pages\
|
||||
ISBN: 9781617297007
|
||||
|
||||
|
||||
### Build Websites with Hugo
|
||||
|
||||
In this book, you'll use Hugo to build a personal portfolio site that you can use to showcase your skills and thoughts to the world. You'll build the basic skeleton, develop a custom theme, and use content templates to generate new pages quickly. You'll use internal and external data sources to embed content into your site, and render some of your content in JSON and RSS. You'll add a blog section with posts and integrate Disqus with your site, and then make your site searchable.
|
||||
|
||||
[{{< img src="build-websites-with-hugo.png" alt="Book cover: Build Websites with Hugo" filter="process" filterArgs="resize x350 webp">}}](https://pragprog.com/titles/bhhugo/build-websites-with-hugo/)
|
||||
|
||||
|
||||
Author: Brian P. Hogan\
|
||||
Publisher: [Pragmatic Bookshelf](https://pragprog.com/titles/bhhugo/build-websites-with-hugo/)\
|
||||
Publication date: May 2020\
|
||||
@@ -60,7 +58,6 @@ Creation date: April 2022
|
||||
|
||||
This course covers the basics of using the Hugo static site generator. Work your way through the articles and we'll teach you everything you need to know to create a professional and scalable website or blog!
|
||||
|
||||
|
||||
1. [Introduction](https://www.giraffeacademy.com/static-site-generators/hugo/)
|
||||
1. [Windows Installation](https://www.giraffeacademy.com/static-site-generators/hugo/installing-hugo-on-windows/)
|
||||
1. [Mac Installation](https://www.giraffeacademy.com/static-site-generators/hugo/installing-hugo-on-mac/)
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
title: slice
|
||||
---
|
||||
|
||||
A numbered sequence of elements. Unlike Go's [array](g) data type, slices are dynamically sized. [Elements](g) within a slice can be [scalars](g) , [arrays](g), [maps](g) , pages, or other slices. See the [Go documentation](https://go.dev/ref/spec#Slice_types) for details.
|
||||
A numbered sequence of elements. Unlike Go's [array](g) data type, slices are dynamically sized. [Elements](g) within a slice can be [scalars](g), [arrays](g), [maps](g), pages, or other slices. See the [Go documentation](https://go.dev/ref/spec#Slice_types) for details.
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
title: template
|
||||
---
|
||||
|
||||
A file with [template actions](g) , located within the `layouts` directory of a project, theme, or module. See [details](/templates/).
|
||||
A file with [template actions](g), located within the `layouts` directory of a project, theme, or module. See [details](/templates/).
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
title: term page
|
||||
---
|
||||
|
||||
Content with the "term" [page kind](g). Typically a listing of [regular pages](g) and [section pages](g) with a given [term](g).
|
||||
Content with the "term" [page kind](g). Typically a listing of [regular pages](g) and [section pages](g) with a given [term](g).
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
title: term
|
||||
---
|
||||
|
||||
A member of a [taxonomy](g) , used to classify content. See [details](/content-management/taxonomies/).
|
||||
A member of a [taxonomy](g), used to classify content. See [details](/content-management/taxonomies/).
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
title: theme
|
||||
---
|
||||
|
||||
A packaged combination of [archetypes](g) , assets, content, data, [templates](g), translation tables, static files, or configuration settings. A theme may serve as the basis for a new site, or to augment an existing site. See also [module](g).
|
||||
A packaged combination of [archetypes](g), assets, content, data, [templates](g), translation tables, static files, or configuration settings. A theme may serve as the basis for a new site, or to augment an existing site. See also [module](g).
|
||||
|
||||
@@ -16,9 +16,9 @@ minVersion: v0.128.0
|
||||
In this tutorial you will:
|
||||
|
||||
1. Create a site
|
||||
2. Add content
|
||||
3. Configure the site
|
||||
4. Publish the site
|
||||
1. Add content
|
||||
1. Configure the site
|
||||
1. Publish the site
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -174,10 +174,8 @@ theme = 'ananke'
|
||||
Make the following changes:
|
||||
|
||||
1. Set the `baseURL` for your production site. This value must begin with the protocol and end with a slash, as shown above.
|
||||
|
||||
2. Set the `languageCode` to your language and region.
|
||||
|
||||
3. Set the `title` for your production site.
|
||||
1. Set the `languageCode` to your language and region.
|
||||
1. Set the `title` for your production site.
|
||||
|
||||
Start Hugo's development server to see your changes, remembering to include draft content.
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ This guide assumes you already have a Hugo project to deploy. If you need a proj
|
||||
You can set up a Hugo site on 21YunBox in two quick steps:
|
||||
|
||||
1. Create a new web service on 21YunBox, and give 21YunBox permission to access your GitHub or Gitee repo.
|
||||
2. Use the following values during creation:
|
||||
1. Use the following values during creation:
|
||||
|
||||
| Field | Value |
|
||||
| --------------------- | ------------------------------------------------ |
|
||||
|
||||
@@ -14,10 +14,10 @@ toc: true
|
||||
Please complete the following tasks before continuing:
|
||||
|
||||
1. [Create an AWS account]
|
||||
2. [Install Git]
|
||||
3. [Create a Hugo site] and test it locally with `hugo server`
|
||||
4. Commit the changes to your local repository
|
||||
5. Push the local repository to your [GitHub], [GitLab], or [Bitbucket] account
|
||||
1. [Install Git]
|
||||
1. [Create a Hugo site] and test it locally with `hugo server`
|
||||
1. Commit the changes to your local repository
|
||||
1. Push the local repository to your [GitHub], [GitLab], or [Bitbucket] account
|
||||
|
||||
[Bitbucket]: https://bitbucket.org/product
|
||||
[Create a Hugo site]: /getting-started/quick-start/
|
||||
|
||||
@@ -15,8 +15,8 @@ aliases: [/tutorials/github-pages-blog/]
|
||||
Please complete the following tasks before continuing:
|
||||
|
||||
1. [Create a GitHub account]
|
||||
2. [Install Git]
|
||||
3. [Create a Hugo site] and test it locally with `hugo server`.
|
||||
1. [Install Git]
|
||||
1. [Create a Hugo site] and test it locally with `hugo server`.
|
||||
|
||||
[Create a GitHub account]: https://github.com/signup
|
||||
[Install Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
|
||||
|
||||
@@ -14,10 +14,10 @@ toc: true
|
||||
Please complete the following tasks before continuing:
|
||||
|
||||
1. [Create a Netlify account]
|
||||
2. [Install Git]
|
||||
3. [Create a Hugo site] and test it locally with `hugo server`
|
||||
4. Commit the changes to your local repository
|
||||
5. Push the local repository to your [GitHub], [GitLab], or [Bitbucket] account
|
||||
1. [Install Git]
|
||||
1. [Create a Hugo site] and test it locally with `hugo server`
|
||||
1. Commit the changes to your local repository
|
||||
1. Push the local repository to your [GitHub], [GitLab], or [Bitbucket] account
|
||||
|
||||
[Bitbucket]: https://bitbucket.org/product
|
||||
[Create a Hugo site]: /getting-started/quick-start/
|
||||
|
||||
@@ -34,7 +34,6 @@ This feature requires the Hugo extended/deploy edition. See the [installation] s
|
||||
* Amazon S3: [create a bucket](https://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html) and [host a static website](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html)
|
||||
* Microsoft Azure: [create a storage container](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal) and [host a static website](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website)
|
||||
|
||||
|
||||
## Configuring your first deployment
|
||||
|
||||
In the configuration file for your site, add a `[deployment]` section
|
||||
@@ -82,7 +81,6 @@ configuration.
|
||||
|
||||
See `hugo help deploy` or [the deploy command-line documentation][commandline] for more command-line options.
|
||||
|
||||
|
||||
### How the file list works
|
||||
|
||||
The first thing `hugo deploy` does is create file lists for local and remote by
|
||||
@@ -95,7 +93,6 @@ the [deployment target's configuration][config] --
|
||||
* If the configuration specifies an `exclude` pattern, files matching the
|
||||
pattern are skipped.
|
||||
|
||||
|
||||
{{% note %}}
|
||||
When creating the local file list, a few additional skips apply: first, Hugo always
|
||||
skips files named `.DS_Store`.
|
||||
@@ -107,8 +104,6 @@ traverse into them, except for the special [hidden directory named
|
||||
traversed if it exists.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
|
||||
### How the local and remote file lists are compared
|
||||
|
||||
In the second step, Hugo compares the two file lists to figure out what changes
|
||||
|
||||
@@ -31,7 +31,7 @@ Also see the [CLI Doc](/commands/hugo_mod_init/).
|
||||
The easiest way to use a Module for a theme is to import it in the configuration.
|
||||
|
||||
1. Initialize the hugo module system: `hugo mod init github.com/<your_user>/<your_project>`
|
||||
2. Import the theme:
|
||||
1. Import the theme:
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
[module]
|
||||
|
||||
@@ -11,5 +11,4 @@ menu:
|
||||
weight: 60
|
||||
---
|
||||
|
||||
|
||||
See [JS functions](/functions/js/).
|
||||
|
||||
@@ -23,7 +23,7 @@ A prime use case for this is [CSS purging with PostCSS](#css-purging-with-postcs
|
||||
There are currently two limitations to this:
|
||||
|
||||
1. This only works in `*.html` templates (i.e. templates that produces HTML files).
|
||||
2. You cannot manipulate the values returned from the resource's methods. E.g. the `upper` in this example will not work as expected:
|
||||
1. You cannot manipulate the values returned from the resource's methods. E.g. the `upper` in this example will not work as expected:
|
||||
|
||||
```go-html-template
|
||||
{{ $css := resources.Get "css/main.css" }}
|
||||
|
||||
@@ -121,8 +121,7 @@ To install the extended edition of Hugo on [Exherbo]:
|
||||
www-apps/hugo extended
|
||||
```
|
||||
|
||||
2. Install using the Paludis package manager:
|
||||
|
||||
1. Install using the Paludis package manager:
|
||||
|
||||
```sh
|
||||
cave resolve -x repository/heirecka
|
||||
@@ -151,7 +150,7 @@ Derivatives of the [Gentoo] distribution of Linux include [Calculate Linux], [Fu
|
||||
www-apps/hugo extended
|
||||
```
|
||||
|
||||
2. Build using the Portage package manager:
|
||||
1. Build using the Portage package manager:
|
||||
|
||||
```sh
|
||||
sudo emerge www-apps/hugo
|
||||
|
||||
@@ -54,7 +54,6 @@ In almost also scenarios you should use the [`URL`] method instead.
|
||||
[`URL`]: /methods/menu-entry/url/
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
Consider this content structure:
|
||||
|
||||
```text
|
||||
@@ -99,7 +98,6 @@ In the above note that the `href` attribute of the second `anchor` element is bl
|
||||
|
||||
With this template code:
|
||||
|
||||
|
||||
{{< code file=layouts/partials/menu.html >}}
|
||||
<ul>
|
||||
{{ range .Site.Menus.main }}
|
||||
|
||||
@@ -32,7 +32,6 @@ weight = 30
|
||||
|
||||
With this template:
|
||||
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ range .Site.Menus.main }}
|
||||
|
||||
@@ -11,7 +11,6 @@ action:
|
||||
|
||||
For menu entries associated with a page, the `URL` method returns the page's [`RelPermalink`], otherwise it returns the entry's `url` property.
|
||||
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ range .Site.Menus.main }}
|
||||
|
||||
@@ -19,7 +19,7 @@ action:
|
||||
{{% include "methods/page/_common/definition-of-section.md" %}}
|
||||
|
||||
{{% note %}}
|
||||
The current section of a [section](g) page, [taxonomy](g) page, [term](g) page, or the home page, is itself.
|
||||
The current section of a [section page](g), [taxonomy page](g), [term page](g), or the home page, is itself.
|
||||
{{% /note %}}
|
||||
|
||||
Consider this content structure:
|
||||
|
||||
@@ -32,7 +32,6 @@ Headings
|
||||
<pre>{{ debug.Dump .Fragments.Headings }}</pre>
|
||||
```
|
||||
|
||||
|
||||
HeadingsMap
|
||||
: (`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ You can invoke pagination on the [home template], [section templates], [taxonomy
|
||||
In the example above, we:
|
||||
|
||||
1. Build a page collection
|
||||
2. Sort the collection by title
|
||||
3. Paginate the collection, with 7 elements per pager
|
||||
4. Range over the paginated page collection, rendering a link to each page
|
||||
5. Call the embedded pagination template to create navigation links between pagers
|
||||
1. Sort the collection by title
|
||||
1. Paginate the collection, with 7 elements per pager
|
||||
1. Range over the paginated page collection, rendering a link to each page
|
||||
1. Call the embedded pagination template to create navigation links between pagers
|
||||
|
||||
{{% note %}}
|
||||
Please note that the results of pagination are cached. Once you have invoked either the `Paginator` or `Paginate` method, the paginated collection is immutable. Additional invocations of these methods will have no effect.
|
||||
|
||||
@@ -34,9 +34,9 @@ The meaning of, and value returned by, the `Path` method on a `Page` object chan
|
||||
To determine the logical path for pages backed by a file, Hugo starts with the file path, relative to the `content` directory, and then:
|
||||
|
||||
1. Strips the file extension
|
||||
2. Strips the language identifier
|
||||
3. Converts the result to lower case
|
||||
4. Replaces spaces with hyphens
|
||||
1. Strips the language identifier
|
||||
1. Converts the result to lower case
|
||||
1. Replaces spaces with hyphens
|
||||
|
||||
The value returned by the `Path` method on a `Page` object is independent of content format, language, and URL modifiers such as the `slug` and `url` front matter fields.
|
||||
|
||||
@@ -121,7 +121,6 @@ Methods|Functions|Shortcodes
|
||||
Specify the logical path when using any of these methods, functions, or shortcodes. If you include a file extension or language identifier, Hugo will strip these values before finding the page in the logical tree.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
## Logical tree
|
||||
|
||||
Just as file paths form a file tree, logical paths form a logical tree.
|
||||
|
||||
@@ -86,7 +86,6 @@ An *emphasized* word.
|
||||
|
||||
Note that the shortcode within the content file was rendered, but the surrounding Markdown was preserved.
|
||||
|
||||
|
||||
## Limitations
|
||||
|
||||
The primary use case for `.RenderShortcodes` is inclusion of Markdown content. If you try to use `.RenderShortcodes` inside `HTML` blocks when inside Markdown, you will get a warning similar to this:
|
||||
|
||||
@@ -82,7 +82,6 @@ When working with global resources instead of page resources, use the [`resource
|
||||
|
||||
This method is currently only useful in [js.Batch](/functions/js/batch/#import-context).
|
||||
|
||||
|
||||
## Pattern matching
|
||||
|
||||
With the `GetMatch` and `Match` methods, Hugo determines a match using a case-insensitive [glob pattern].
|
||||
|
||||
@@ -49,6 +49,5 @@ This is similar to using the [`Type`] method with the `where` function
|
||||
|
||||
However, if the `type` field in front matter has been defined on one or more pages, the page collection based on `Type` will be different than the page collection based on `Section`.
|
||||
|
||||
|
||||
[`where`]: /functions/collections/where/
|
||||
[`Type`]: /methods/page/type/
|
||||
|
||||
@@ -45,7 +45,6 @@ To pass an options map:
|
||||
{{ end }}
|
||||
{{< /code >}}
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
indices
|
||||
|
||||
@@ -169,7 +169,6 @@ Calculate the contrast ratio to determine WCAG conformance:
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
|
||||
[WCAG]: https://en.wikipedia.org/wiki/Web_Content_Accessibility_Guidelines
|
||||
[contrast ratio]: https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio
|
||||
[enhanced]: https://www.w3.org/WAI/WCAG22/quickref/?showtechniques=145#contrast-enhanced
|
||||
|
||||
@@ -38,7 +38,6 @@ We used the [`resources.Copy`] function to change the publishing path. The `Key`
|
||||
|
||||
The `Key` method is useful if you need to get the resource's publishing path without publishing the resource. Unlike the `Permalink`, `RelPermalink`, or `Publish` methods, calling `Key` will not publish the resource.
|
||||
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
[`Permalink`]: /methods/resource/permalink/
|
||||
|
||||
@@ -56,7 +56,6 @@ Content between opening and closing shortcode tags may include leading and/or tr
|
||||
In the example above, the value returned by `Inner` is Markdown, but it was rendered as plain text. Use either of the following approaches to render Markdown to HTML.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
## Use RenderString
|
||||
|
||||
Let's modify the example above to pass the value returned by `Inner` through the [`RenderString`] method on the `Page` object:
|
||||
|
||||
@@ -46,5 +46,5 @@ Welcome. Today is {{</* now */>}}.
|
||||
The "now" shortcode formats the current time using:
|
||||
|
||||
1. The `dateFormat` argument passed to the "now" shortcode, if present
|
||||
2. The `dateFormat` argument passed to the "greeting" shortcode, if present
|
||||
3. The default layout string defined at the top of the shortcode
|
||||
1. The `dateFormat` argument passed to the "greeting" shortcode, if present
|
||||
1. The default layout string defined at the top of the shortcode
|
||||
|
||||
@@ -16,7 +16,6 @@ The `Param` method on a `Site` object is a convenience method to return the valu
|
||||
display_toc = true
|
||||
{{< /code-toggle >}}
|
||||
|
||||
|
||||
```go-html-template
|
||||
{{ .Site.Param "display_toc" }} → true
|
||||
```
|
||||
|
||||
@@ -73,7 +73,6 @@ authors:
|
||||
- Pride and Prejudice
|
||||
{{< /code-toggle >}}
|
||||
|
||||
|
||||
To list the "suspense" books:
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -59,7 +59,6 @@ Although the [`Alphabetical`] and [`ByCount`] methods provide a better data stru
|
||||
|
||||
In the example above, the first anchor element is a link to the term page.
|
||||
|
||||
|
||||
[`Alphabetical`]: /methods/taxonomy/alphabetical/
|
||||
[`ByCount`]: /methods/taxonomy/bycount/
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ byline: "[bep](https://github.com/bep), Hugo Lead"
|
||||
To complete this showcase:
|
||||
|
||||
1. Write the story about your site in this file.
|
||||
2. Add a summary to the `bio.md` file in this directory.
|
||||
3. Replace the `featured-template.png` with a screenshot of your site. You can rename it, but it must contain the word `featured`.
|
||||
4. Create a new pull request in https://github.com/gohugoio/hugoDocs/pulls
|
||||
1. Add a summary to the `bio.md` file in this directory.
|
||||
1. Replace the `featured-template.png` with a screenshot of your site. You can rename it, but it must contain the word `featured`.
|
||||
1. Create a new pull request in https://github.com/gohugoio/hugoDocs/pulls
|
||||
|
||||
The content of this bundle explained:
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ toc: true
|
||||
|
||||
## Page
|
||||
|
||||
Use these `Page` methods when rendering lists on [section](g) pages, [taxonomy](g) pages, [term](g) pages, and the home page.
|
||||
assets/
|
||||
Use these `Page` methods when rendering lists on [section pages](g), [taxonomy pages](g), [term pages](g), and the home page.
|
||||
|
||||
{{< list-pages-in-section path=/methods/page filter=methods_page_page_collections filterType=include omitElementIDs=true titlePrefix=PAGE. >}}
|
||||
|
||||
@@ -34,9 +35,9 @@ Use the [`where`] function to filter page collections.
|
||||
By default, Hugo sorts page collections by:
|
||||
|
||||
1. [Weight]
|
||||
2. [Date] in descending order
|
||||
3. [LinkTitle] falling back to [Title]
|
||||
4. [Filename] if the page is backed by a file
|
||||
1. [Date] in descending order
|
||||
1. [LinkTitle] falling back to [Title]
|
||||
1. [Filename] if the page is backed by a file
|
||||
|
||||
[Date]: /methods/page/date/
|
||||
[Weight]: /methods/page/weight/
|
||||
|
||||
@@ -51,7 +51,7 @@ OPTIONS
|
||||
: (`string`) Zero or more space-separated key-value pairs wrapped in quotation marks. Set default values for each option in your [site configuration]. The key names are case-insensitive.
|
||||
|
||||
[site configuration]: /getting-started/configuration-markup#highlight
|
||||
[supported languages]: https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages
|
||||
[supported languages]: /content-management/syntax-highlighting/#list-of-chroma-highlighting-languages
|
||||
|
||||
## Example
|
||||
|
||||
@@ -102,7 +102,6 @@ Given the verbosity of the example above, if you need to frequently highlight in
|
||||
{{ transform.Highlight $code $lang $opts }}
|
||||
{{< /code >}}
|
||||
|
||||
|
||||
```text
|
||||
This is some {{</* hl */>}}fmt.Println("inline"){{</* /hl */>}} code.
|
||||
```
|
||||
|
||||
@@ -37,7 +37,6 @@ Rendered:
|
||||
|
||||
{{< x user="SanDiegoZoo" id="1453110110599868418" >}}
|
||||
|
||||
|
||||
## Privacy
|
||||
|
||||
Adjust the relevant privacy settings in your site configuration.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
---
|
||||
title: Showcases
|
||||
draft: true
|
||||
---
|
||||
---
|
||||
|
||||
@@ -4,4 +4,3 @@
|
||||
The site is built by:
|
||||
|
||||
* [Tobias Kummer](https://www.overmind-studios.de/about/)
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ Have a **notable Hugo site[^1]**? We would love to feature it in this **Showcase
|
||||
Please:
|
||||
|
||||
1. Fork https://github.com/gohugoio/hugoDocs.
|
||||
2. Run `hugo new content showcase/your-site`. This will use the archetype bundle in the [docs repo](https://github.com/gohugoio/hugoDocs/tree/master/archetypes).
|
||||
3. Follow the instructions in the newly created page bundle.
|
||||
4. Create a new pull request in https://github.com/gohugoio/hugoDocs/pulls.
|
||||
1. Run `hugo new content showcase/your-site`. This will use the archetype bundle in the [docs repo](https://github.com/gohugoio/hugoDocs/tree/master/archetypes).
|
||||
1. Follow the instructions in the newly created page bundle.
|
||||
1. Create a new pull request in https://github.com/gohugoio/hugoDocs/pulls.
|
||||
|
||||
[^1]: We want this to show Hugo in its best light, so this is not for the average Hugo blog. In most cases the answer to "Is my site [notable](https://www.dictionary.com/browse/notable)?" will be obvious, but if in doubt, create an [issue](https://github.com/gohugoio/hugoDocs/issues) with a link and some words, and we can discuss it. But if you have a site with an interesting Hugo story or a company site where the company itself is notable, you are most welcome.
|
||||
|
||||
@@ -14,7 +14,6 @@ aliases: [/layout/homepage/,/templates/homepage-template/,/templates/homepage/]
|
||||
|
||||
The home template is the *only* required template for building a site and therefore useful when bootstrapping a new site and template. It is also the only required template if you are developing a single-page website.
|
||||
|
||||
|
||||
{{< youtube ut1xtRZ1QOA >}}
|
||||
|
||||
## Home template lookup order
|
||||
|
||||
@@ -376,7 +376,7 @@ Use the [`template`] function to include one or more of Hugo's [embedded templat
|
||||
|
||||
[`partial`]: /functions/partials/include/
|
||||
[`partialCached`]: /functions/partials/includecached/
|
||||
[`template`]: functions/go-template/template/
|
||||
[`template`]: /functions/go-template/template/
|
||||
|
||||
Use the [`partial`] or [`partialCached`] function to include one or more [partial templates]:
|
||||
|
||||
|
||||
@@ -114,11 +114,10 @@ To paginate a list page using the `Paginate` method:
|
||||
In the example above, we:
|
||||
|
||||
1. Build a page collection
|
||||
2. Sort the page collection by title
|
||||
3. Paginate the page collection, with 7 pages per pager
|
||||
4. Range over the paginated page collection, rendering a link to each page
|
||||
5. Call the embedded pagination template to create navigation links between pagers
|
||||
|
||||
1. Sort the page collection by title
|
||||
1. Paginate the page collection, with 7 pages per pager
|
||||
1. Range over the paginated page collection, rendering a link to each page
|
||||
1. Call the embedded pagination template to create navigation links between pagers
|
||||
|
||||
To paginate a list page using the `Paginator` method:
|
||||
|
||||
@@ -133,8 +132,8 @@ To paginate a list page using the `Paginator` method:
|
||||
In the example above, we:
|
||||
|
||||
1. Paginate the page collection passed into the template, with the default number of pages per pager
|
||||
2. Range over the paginated page collection, rendering a link to each page
|
||||
3. Call the embedded pagination template to create navigation links between pagers
|
||||
1. Range over the paginated page collection, rendering a link to each page
|
||||
1. Call the embedded pagination template to create navigation links between pagers
|
||||
|
||||
## Caching
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ Search engines that honor the Robots Exclusion Protocol will interpret this as p
|
||||
You may overwrite the internal template with a custom template. Hugo selects the template using this lookup order:
|
||||
|
||||
1. `/layouts/robots.txt`
|
||||
2. `/themes/<THEME>/layouts/robots.txt`
|
||||
1. `/themes/<THEME>/layouts/robots.txt`
|
||||
|
||||
## robots.txt template example
|
||||
|
||||
@@ -50,7 +50,7 @@ This template creates a robots.txt file with a `Disallow` directive for each pag
|
||||
To create a robots.txt file without using a template:
|
||||
|
||||
1. Set `enableRobotsTXT` to `false` in the site configuration.
|
||||
2. Create a robots.txt file in the `static` directory.
|
||||
1. Create a robots.txt file in the `static` directory.
|
||||
|
||||
Remember that Hugo copies everything in the [`static` directory][static] to the root of `publishDir` (typically `public`) when you build your site.
|
||||
|
||||
|
||||
@@ -79,4 +79,4 @@ disableKinds = ['sitemap']
|
||||
{{</ code-toggle >}}
|
||||
|
||||
[`publishDir`]: /getting-started/configuration#publishdir
|
||||
[sitemap protocol]: <https://www.sitemaps.org/protocol.html>
|
||||
[sitemap protocol]: https://www.sitemaps.org/protocol.html
|
||||
|
||||
@@ -46,7 +46,6 @@ A static website with a dynamic search function? Yes, Hugo provides an alternati
|
||||
[INFINI Pizza for WebAssembly](https://github.com/infinilabs/pizza-docsearch)
|
||||
: Pizza is a super-lightweight yet fully featured search engine written in Rust. You can quickly add offline search functionality to your Hugo website in just five minutes with only three lines of code. For a step-by-step guide on integrating it with Hugo, check out [this blog tutorial](https://dev.to/medcl/adding-search-functionality-to-a-hugo-static-site-based-on-infini-pizza-for-webassembly-4h5e).
|
||||
|
||||
|
||||
## Commercial
|
||||
|
||||
[Algolia](https://www.algolia.com/)
|
||||
|
||||
@@ -13,8 +13,8 @@ weight: 50
|
||||
When a project _deprecates_ something, they are telling its users:
|
||||
|
||||
1. Don't use Thing One anymore.
|
||||
2. Use Thing Two instead.
|
||||
3. We're going to remove Thing One at some point in the future.
|
||||
1. Use Thing Two instead.
|
||||
1. We're going to remove Thing One at some point in the future.
|
||||
|
||||
[reasons for deprecation]: https://en.wikipedia.org/wiki/Deprecation
|
||||
|
||||
@@ -30,8 +30,8 @@ Common [reasons for deprecation]:
|
||||
After the project team deprecates something in code, Hugo will:
|
||||
|
||||
1. Log an INFO message for 6 minor releases[^1]
|
||||
2. Log a WARN message for another 6 minor releases
|
||||
3. Log an ERROR message and fail the build thereafter
|
||||
1. Log a WARN message for another 6 minor releases
|
||||
1. Log an ERROR message and fail the build thereafter
|
||||
|
||||
To see the INFO messages, you must use the `--logLevel` command line flag:
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ menu:
|
||||
parent: troubleshooting
|
||||
weight: 70
|
||||
weight: 70
|
||||
# Use level 6 headings for each question.
|
||||
---
|
||||
|
||||
Hugo’s [forum] is an active community of users and developers who answer questions, share knowledge, and provide examples. A quick search of over 20,000 topics will often answer your question. Please be sure to read about [requesting help] before asking your first question.
|
||||
@@ -43,10 +42,10 @@ If the answer to any of these questions is yes, either change the field values,
|
||||
|
||||
In the `content/section/page.md` file, or in the `content/section/page/index.md` file:
|
||||
|
||||
- Is `draft` set to `true`?
|
||||
- Is the `date` in the future?
|
||||
- Is the `publishDate` in the future?
|
||||
- Is the `expiryDate` in the past?
|
||||
- Is `draft` set to `true`?
|
||||
- Is the `date` in the future?
|
||||
- Is the `publishDate` in the future?
|
||||
- Is the `expiryDate` in the past?
|
||||
|
||||
If the answer to any of these questions is yes, either change the field values, or use one of these command line flags: `--buildDrafts`, `--buildFuture`, or `--buildExpired`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user