Squashed 'docs/' changes from 71f739460..1ad3c75ad

1ad3c75ad theme: Run ncu -u to update dependencies (#3311)
2942d3753 content: Update version refs
e298fdfaf content: Remove ref to old version
c1fc876ea content: Improve taxonomic weight example
d706a013d content: Document additional functions
5751c37cc content: Standardize string function signatures
d65e6fae7 misc: Add data/docs.yaml to ignorePaths in cspell config
ba1f98a32 content: Improve collections.First/Last string examples
d7b5a2efd content: Improve collections.First/Last examples
e94e49db2 content: Add Smart Hugo to editor plugins
af204597a content: Clarify config description
9d1cb33cd content: Fix typo
dded23962 content: Clarify note on rare use case for PageRef method
8af9e3be4 content: Update the Homebrew installation description
be56390b3 content: Clarify command description
fa228e9f0 content: Clarify AsciiDoc extensions setting description
3a23a4af2 docs: Add best practices for manual summary marker placement
050d7c75e misc: Fix cspell configuration
74642b18d content: Miscellaneous edits
75a2c8425 content: Add missing reference definitions
6303f27e1 content: Improve description of the SITE.Home method
4dfbd647f Revert the minimal analytics changes (#3265)
c369e534d theme: Move tracking to turbo:load
88b451022 theme: Move tracking to turbo:render
7040dc5ee Move to minimalanalytics for GA tracking
4e8a523fb content: Update KaTeX link attributes to v0.16.25 (phase 2)
21046b942 content: Update KaTeX link attributes to v0.16.25 (phase 1)
b8df9d941 theme: Use Path for the glossary link destination
acd6c2954 theme: Use page Path when generating Markdown links
543f78340 content: Fix formatting
aef89d192 content: Correct page collection quick-reference data
08645236a content: Use RSS output format in shortcode lookup example
58654c106 content: Fix archetype lookup order
9f79bacc4 content: Describe valid uses of the nil keyword
41f139d14 theme: Remove the root view transition
6ab407bb9 content: Improve links on lang.Translate page
91e724065 content: Add missing fragments to links in the module mounts description
2f6b4a58c content: Clarify ByCount sort order
8594590b2 Update netlify.toml
811574060 content: Update version references
a12bcf7dd content: Update version references
23ca199ed Update netlify.toml
5d3da2351 content: Update version references
1617ee75b misc: Update Netlify config to build with v0.152.0
6467bda93 content: Remove outdated new-in badges
4b3ef4bd5 content: Improve description of default mount behavior
5a861f500 content: Revise partials.IncludeCached description and signature
2ad9d705a content: Correct the partials.IncludeCached signature
9f611b879 Update netlify.toml
ca21f5fbd content: Add warning about automatic summaries
2065fadde content: Update commit message guidelines
a0784f261 content: Remove outdated new-in badges
ce5a249f2 content: Remove Codeberg Pages documentation
3424b95f2 content: Update CLI docs
27fd350a6 content: Change KaTeX version references to 0.16.23
ba8c5fd3b content: Change MathJax version reference from v3 to v4
c83465222 content: Fix broken link
c6cde1074 content: Update version references
467277939 content: Fix typo
e424b6b19 content: Document new features in v0.151.0
a46898f79 Update netlify.toml
f8407c3b5 content: Enhance content view template details
974175690 content: Optionally disable whitespace trimming in fenced code blocks
25bffc4c4 Update netlify.toml
98e9ef5f0 theme: Move initColorScheme() to head
a1566495b theme: Preload fonts (#3209)
c0271d266 content: Add missing word in deploy-with-rsync.md
47099c4fa content: Remove outdated new-in badges
439b5c18b content: Fix collections.D seed example
d2486ba67 content: Update description of IsNode method
4de8815e9 content: Update description of the cascade front matter field
0801e9b3f content: Fix broken link
9bbbfb59d content: Update Netlify hosting guide and version refs
4f444fb53 misc: Update docs.yaml
a7a9a7563 Update module.md
a7909fe37 Update netlify.toml
47a2c2038 content: Update collections.D page to remove casting note
ecca5ef48 content: Update summaryLength description with default value
310e11195 content: Change alias example
bd6b53b5d content: Update minify config documentation
21bb0bb66 Update netlify.toml
68912f1a3 content: Update version reference
28a47a50f content: Fix missing link to latest release under Prebuilt Binaries
8eac2a120 theme: Revise inline code span styling
2e71b6d0a Adjust sponsor
d93340a78 content: Update documentation guide
9f6213ebe content: Fix glob pattern-alternatives syntax in cascade.md
1f61fd6be content: Add seed examples to collections.D
65385a5d0 content: Fix Cloudflare deploy not_found_handling value
4f70df235 content: Fix typo
fc216f2d9 content: Fix broken link
e98b340f2 Update cascade.md
e316dbf93 content: Update version references
f8e863e97 misc: Remove textlint config file
3b9c3e2a1 content: Miscellaneous updates related to v0.149.0
3ccc439fc Update netlify.toml
07f5140e8 Merge branch 'tempv0.149.0'
17f8d33d8 content: Add format option to transform.Unmarshal
a6a971596 content: Document the collections.D function
66eee712b content: Update front matter configuration example
863945e13 content: Update fmt.Println example
1d9a92bc7 theme: Don't exclude current section from related content
1386d8ed2 Update introduction.md
0ac89b015 content: Replace inline URLs with autolinks
54fad1e01 content: Fix typo
e09f6b0c5 content: Wrap calls to eturl shortcode in angle brackets
23efd9766 Merge commit 'bfa74537929f409fca841540b971125b7678963a'
e98754e72 resources/page: Add :sectionslug and :sectionslugs permalink tokens

git-subtree-dir: docs
git-subtree-split: 1ad3c75ad0e997d66598c1453db9989fde7d9680
This commit is contained in:
Bjørn Erik Pedersen
2025-12-19 10:04:19 +01:00
parent bfa7453792
commit 08e1ea5c70
167 changed files with 1009 additions and 751 deletions
+6 -3
View File
@@ -23,7 +23,8 @@
"**/emojis.md",
"**/commands/*",
"**/showcase/*",
"**/tools/*"
"**/tools/*",
"data/docs.yaml"
],
"ignoreRegExpList": [
"# cspell: ignore fenced code blocks",
@@ -59,12 +60,14 @@
"marshal",
"marshaling",
"multihost",
"multiplatfom",
"multiplatform",
"performantly",
"preconfigured",
"prerendering",
"redirection",
"redirections",
"slugified",
"slugify",
"subexpression",
"suppressible",
"synchronisation",
@@ -113,7 +116,6 @@
"libros",
"mercredi",
"miesiąc",
"miesiąc",
"miesiąca",
"miesiące",
"miesięcy",
@@ -144,6 +146,7 @@
"Samsa",
"Stucki",
"Thénardier",
"Vitter",
"WASI",
"# ----------------------------------------------------------------------",
"# cspell: ignore operating systems and software packages",
+1 -1
View File
@@ -77,7 +77,7 @@ config:
full: true
inline: true
shortcut: true
url_inline: true
url_inline: false
MD055:
style: consistent
MD056: true
-3
View File
@@ -1,3 +0,0 @@
**/news/**
**/showcase/**
**/zh/**
+5
View File
@@ -129,3 +129,8 @@ body {
text-decoration: none;
padding-left: .0625em;
}
/* Code spans within paragraphs, tables cells, list items, etc. */
:not(pre) > code {
white-space: nowrap;
}
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 13 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 13 KiB

-6
View File
@@ -1,6 +0,0 @@
import { initColorScheme } from './alpinejs/stores/index';
(function () {
// This allows us to initialize the color scheme before AlpineJS etc. is loaded.
initColorScheme();
})();
+4
View File
@@ -1,6 +1,10 @@
import { scrollToActive } from 'js/helpers/index';
import { initColorScheme } from './alpinejs/stores/index';
(function () {
// This allows us to initialize the color scheme before AlpineJS etc. is loaded.
initColorScheme();
// Now we know that the browser has JS enabled.
document.documentElement.classList.remove('no-js');
-8
View File
@@ -8,14 +8,6 @@ import focus from '@alpinejs/focus';
var debug = 0 ? console.log.bind(console, '[index]') : function () {};
// Turbolinks init.
(function () {
document.addEventListener('turbo:render', function (e) {
// This is also called right after the body start. This is added to prevent flicker on navigation.
initColorScheme();
});
})();
// Set up and start Alpine.
(function () {
// Register AlpineJS plugins.
@@ -29,6 +29,7 @@ Please refer to the relevant documentation for installation instructions:
[cloudcannon]: https://cloudcannon.com/
[cloudflare pages]: https://pages.cloudflare.com/
[commit information]: /methods/page/GitInfo
[dart sass install]: /functions/css/sass/#dart-sass
[dart sass]: https://sass-lang.com/dart-sass
[git install]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
@@ -37,4 +38,5 @@ Please refer to the relevant documentation for installation instructions:
[gitlab pages]: https://docs.gitlab.com/ee/user/project/pages/
[go install]: https://go.dev/doc/install
[go]: https://go.dev/
[hugo modules]: /hugo-modules/
[netlify]: https://www.netlify.com/
@@ -15,3 +15,5 @@ Prebuilt binaries are available for a variety of operating systems and architect
Please consult your operating system documentation if you need help setting file permissions or modifying your PATH environment variable.
If you do not see a prebuilt binary for the desired edition, operating system, and architecture, install Hugo using one of the methods described below.
[latest release]: https://github.com/gohugoio/hugo/releases/latest
@@ -7,7 +7,7 @@ _comment: Do not remove front matter.
To build the extended or extended/deploy edition from source you must:
1. Install [Git]
1. Install [Go] version 1.23.0 or later
1. Install [Go] version 1.24.0 or later
1. Install a C compiler, either [GCC] or [Clang]
1. Update your `PATH` environment variable as described in the [Go documentation]
+1 -1
View File
@@ -4,7 +4,7 @@ _comment: Do not remove front matter.
### Homebrew
[Homebrew] is a free and open-source package manager for macOS and Linux. To install the extended edition of Hugo:
[Homebrew] is a free and open-source package manager for macOS and Linux. To install the extended/deploy edition of Hugo:
```sh
brew install hugo
+8
View File
@@ -26,9 +26,17 @@ _comment: Do not remove front matter.
`:section`
: The content's section.
`:sectionslug`
: {{< new-in 0.149.0 />}}
: The content's section using slugified section name. The slugified section name is the `slug` as defined in front matter, else the `title` as defined in front matter, else the automatic title.
`:sections`
: 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.
`:sectionslugs`
: {{< new-in 0.149.0 />}}
: The content's sections hierarchy using slugified section names. The slugified section name is the `slug` as defined in front matter, else the `title` as defined in front matter, else the automatic title. You can use a selection of the sections using _slice syntax_: `:sectionslugs[1:]` includes all but the first, `:sectionslugs[:last]` includes all but the last, `:sectionslugs[last]` includes only the last, `:sectionslugs[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 `title` as defined in front matter, else the automatic title. Hugo generates titles automatically for section, taxonomy, and term pages that are not backed by a file.
+2 -2
View File
@@ -43,5 +43,5 @@ As a practical example, Hugo's embedded link and image render hooks use the `Pag
[`RenderShortcodes`]: /methods/page/rendershortcodes/
[Markdown notation]: /content-management/shortcodes/#notation
[Embedded link render hook]: {{% eturl render-link %}}
[Embedded image render hook]: {{% eturl render-image %}}
[Embedded link render hook]: <{{% eturl render-link %}}>
[Embedded image render hook]: <{{% eturl render-image %}}>
+1 -1
View File
@@ -28,7 +28,7 @@ Learn more about Hugo's [features], [privacy protections], and [security model].
[Hugo Modules]: /hugo-modules/
[static site generator]: https://en.wikipedia.org/wiki/Static_site_generator
[features]: /about/features/
[security model]: about/security/
[security model]: /about/security/
[privacy protections]: /configuration/privacy
{{< youtube 0RKpf3rK57I >}}
@@ -24,6 +24,8 @@ hugo gen chromastyles [flags] [args]
--highlightStyle string foreground and background colors for highlighted lines, e.g. --highlightStyle "#fff000 bg:#000fff"
--lineNumbersInlineStyle string foreground and background colors for inline line numbers, e.g. --lineNumbersInlineStyle "#fff000 bg:#000fff"
--lineNumbersTableStyle string foreground and background colors for table line numbers, e.g. --lineNumbersTableStyle "#fff000 bg:#000fff"
--omitClassComments omit CSS class comment prefixes in the generated CSS
--omitEmpty omit empty CSS rules (deprecated, no longer needed)
--style string highlighter style (see https://xyproto.github.io/splash/docs/) (default "friendly")
```
+2 -2
View File
@@ -45,6 +45,6 @@ Ensure you run this within the root directory of your site.
* [hugo](/commands/hugo/) - Build your site
* [hugo new content](/commands/hugo_new_content/) - Create new content
* [hugo new site](/commands/hugo_new_site/) - Create a new site (skeleton)
* [hugo new theme](/commands/hugo_new_theme/) - Create a new theme (skeleton)
* [hugo new site](/commands/hugo_new_site/) - Create a new site
* [hugo new theme](/commands/hugo_new_theme/) - Create a new theme
+2 -4
View File
@@ -5,13 +5,11 @@ url: /commands/hugo_new_site/
---
## hugo new site
Create a new site (skeleton)
Create a new site
### Synopsis
Create a new site in the provided directory.
The new site will have the correct structure, but no content or theme yet.
Use `hugo new [contentPath]` to create new content.
Create a new site at the specified path.
```
hugo new site [path] [flags]
+5 -6
View File
@@ -5,14 +5,12 @@ url: /commands/hugo_new_theme/
---
## hugo new theme
Create a new theme (skeleton)
Create a new theme
### Synopsis
Create a new theme (skeleton) called [name] in ./themes.
New theme is a skeleton. Please add content to the touched files. Add your
name to the copyright line in the license and adjust the theme.toml file
according to your needs.
Create a new theme with the specified name in the ./themes directory.
This generates a functional theme including template examples and sample content.
```
hugo new theme [name] [flags]
@@ -21,7 +19,8 @@ hugo new theme [name] [flags]
### Options
```
-h, --help help for theme
--format string preferred file format (toml, yaml or json) (default "toml")
-h, --help help for theme
```
### Options inherited from parent commands
+5 -5
View File
@@ -47,7 +47,7 @@ cascade
: See [configure cascade](/configuration/cascade/).
cleanDestinationDir
: (`bool`) Whether to remove files from the site's destination directory that do not have corresponding files in the `static` directory during the build. Default is `false`.
: (`bool`) Whether to remove files from the [`publishDir`](#publishdir) that do not exist in the [`staticDir`](#staticdir) when building the site. This setting will not take effect if the `staticDir` does not exist. Note that `.gitignore` and `.gitattributes` files, along with directories named `.git`, are always preserved in the `publishDir`. Default is `false`.
contentDir
: (`string`) The designated directory for content files. Default is `content`. {{% module-mounts-note %}}
@@ -262,7 +262,7 @@ staticDir
: (`string`) The designated directory for static files. Default is `static`. {{% module-mounts-note %}}
summaryLength
: (`int`) Applicable to [automatic summaries], the minimum number of words returned by the [`Summary`] method on a `Page` object. The `Summary` method will return content truncated at the paragraph boundary closest to the specified `summaryLength`, but at least this minimum number of words.
: (`int`) Applicable to [automatic summaries], the minimum number of words returned by the [`Summary`] method on a `Page` object. The `Summary` method will return content truncated at the paragraph boundary closest to the specified `summaryLength`, but at least this minimum number of words. Default is `70`.
taxonomies
: See [configure taxonomies](/configuration/taxonomies/).
@@ -350,9 +350,9 @@ Some configuration settings, such as menus and custom parameters, can be defined
[Chicago Manual of Style]: https://www.chicagomanualofstyle.org/home.html
[default front matter configuration]: /configuration/front-matter/
[duration]: https://pkg.go.dev/time#Duration
[embedded alias template]: {{% eturl alias %}}
[embedded Open Graph template]: {{% eturl opengraph %}}
[embedded RSS template]: {{% eturl rss %}}
[embedded alias template]: <{{% eturl alias %}}>
[embedded Open Graph template]: <{{% eturl opengraph %}}>
[embedded RSS template]: <{{% eturl rss %}}>
[IANA Time Zone Database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[module mounts]: /configuration/module/#mounts
[os.UserCacheDir]: https://pkg.go.dev/os#UserCacheDir
+2 -3
View File
@@ -14,7 +14,6 @@ You can configure your site to cascade front matter values to the home page and
For example, to cascade a "color" parameter to the home page and all its descendants:
{{< code-toggle file=hugo >}}
title = 'Home'
[cascade.params]
color = 'red'
{{< /code-toggle >}}
@@ -61,14 +60,14 @@ Define an array of cascade parameters to apply different values to different tar
[cascade.params]
color = 'red'
[cascade.target]
path = '{/books/**}'
path = '/books/**'
kind = 'page'
lang = '{en,de}'
[[cascade]]
[cascade.params]
color = 'blue'
[cascade.target]
path = '{/films/**}'
path = '/films/**'
kind = 'page'
environment = 'production'
{{< /code-toggle >}}
+2 -1
View File
@@ -90,10 +90,11 @@ Consider this site configuration:
{{< code-toggle file=hugo >}}
[frontmatter]
date = [':filename', ':default']
publishDate = [':filename', ':default']
lastmod = ['lastmod', ':fileModTime']
{{< /code-toggle >}}
To determine `date`, Hugo tries to extract the date from the file name, falling back to the default ordered sequence of date fields.
To determine `date` and `publishDate`, Hugo tries to extract the value from the file name, falling back to the default ordered sequence of date fields.
To determine `lastmod`, Hugo looks for a `lastmod` field in front matter, falling back to the file's last modification timestamp.
+34 -12
View File
@@ -44,20 +44,42 @@ The HTTP cache involves two key aspects: determining which content to cache (the
The HTTP cache behavior is defined for a configured set of resources. Stale resources will be refreshed from the file cache, even if their configured Time-To-Live (TTL) has not expired. If HTTP caching is disabled for a resource, Hugo will bypass the cache and access the file directly.
The default configuration disables everything:
This is the default configuration for HTTP caching:
{{< code-toggle file=hugo >}}
[HTTPCache.cache.for]
excludes = ['**']
includes = []
{{< /code-toggle >}}
{{< code-toggle config=HTTPCache />}}
respectCacheControlNoStoreInRequest
: {{< new-in 0.151.0 />}}
: (`bool`) Whether to respect the `no-store` directive in the server's `Cache-Control` request header when fetching remote resources via the [`resources.GetRemote`][] function. Default is `true`.
respectCacheControlNoStoreInResponse
: {{< new-in 0.151.0 />}}
: (`bool`) Whether to respect the `no-store` directive in the server's `Cache-Control` response header when fetching remote resources via the [`resources.GetRemote`][] function. Default is `false`.
cache.for.excludes
: (`string`) A list of [glob](g) patterns to exclude from caching.
: (`string`) A list of [glob](g) patterns to exclude from caching. In its default configuration HTTP caching excludes all files.
cache.for.includes
: (`string`) A list of [glob](g) patterns to cache.
polls
: A slice of polling configurations.
polls.disable
: (`bool`) Whether to disable polling for this configuration. Default is `true`.
polls.high
: (`string`) The maximum polling interval expressed as a [duration](g). This is used when the resource is considered stable. Default is `0s`.
polls.low
: (`string`) The minimum polling interval expressed as a [duration](g). This is used after a recent change and gradually increases towards `polls.high`. Default is `0s`.
polls.for.excludes
: (`string`) A list of [glob](g) patterns to exclude from polling for this configuration.
polls.for.includes
: (`string`) A list of [glob](g) patterns to include in polling for this configuration.
## HTTP polling
Polling is used in watch mode (e.g., `hugo server`) to detect changes in remote resources. Polling can be enabled even if HTTP caching is disabled. Detected changes trigger a rebuild of pages using the affected resource. Polling can be disabled for specific resources, typically those known to be static.
@@ -78,13 +100,13 @@ polls
: A slice of polling configurations.
polls.disable
: (`bool`) Whether to disable polling for this configuration.
polls.low
: (`string`) The minimum polling interval expressed as a [duration](g). This is used after a recent change and gradually increases towards `polls.high`.
: (`bool`) Whether to disable polling for this configuration. Default is `true`.
polls.high
: (`string`) The maximum polling interval expressed as a [duration](g). This is used when the resource is considered stable.
: (`string`) The maximum polling interval expressed as a [duration](g). This is used when the resource is considered stable. Default is `0s`.
polls.low
: (`string`) The minimum polling interval expressed as a [duration](g). This is used after a recent change and gradually increases towards `polls.high`. Default is `0s`.
polls.for.excludes
: (`string`) A list of [glob](g) patterns to exclude from polling for this configuration.
+3 -3
View File
@@ -185,9 +185,9 @@ public
[`Language.LanguageName`]: /methods/site/language/#languagename
[`Language.Weight`]: /methods/site/language/#weight
[`Title`]: /methods/site/title/
[embedded alias template]: {{% eturl alias %}}
[embedded OpenGraph template]: {{% eturl opengraph %}}
[embedded RSS template]: {{% eturl rss %}}
[embedded alias template]: <{{% eturl alias %}}>
[embedded OpenGraph template]: <{{% eturl opengraph %}}>
[embedded RSS template]: <{{% eturl rss %}}>
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.1
[RFC 5646 § 2.2.7]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.2.7
[translating by file name]: /content-management/multilingual/#translation-by-file-name
+17 -3
View File
@@ -94,9 +94,23 @@ enable = true
With this configuration, to format text as deleted, wrap it with double-tildes.
#### Passthrough
#### Footnote
{{< new-in 0.122.0 />}}
Enabled by default, the Footnote extension enables inclusion of footnotes in Markdown.
enable
: {{< new-in 0.151.0 />}}
: (`bool`) Whether to enable the Footnotes extension. Default is `true`.
backlinkHTML
: {{< new-in 0.151.0 />}}
: (`string`) The HTML to be displayed at the end of a footnote that links the user back to the corresponding reference in the main text. The default is &#x21a9;&#xfe0e; (a return arrow symbol).
enableAutoIDPrefix
: {{< new-in 0.151.0 />}}
: (`bool`) Whether to prepend a unique prefix to footnote IDs, preventing clashes when multiple documents are rendered together. This prefix is unique to each logical path, which means that the prefix is not unique across content dimensions such as language. Default is `false`.
#### Passthrough
Enable the Passthrough extension to include mathematical equations and expressions in Markdown using LaTeX markup. See [mathematics in Markdown] for details.
@@ -202,7 +216,7 @@ backend
: (`string`) The backend output file format. Default is `html5`.
extensions
: (`string array`) An array of enabled extensions, one or more of `asciidoctor-html5s`, `asciidoctor-bibtex`, `asciidoctor-diagram`, `asciidoctor-interdoc-reftext`, `asciidoctor-katex`, `asciidoctor-latex`, `asciidoctor-mathematical`, or `asciidoctor-question`.
: (`string array`) An array of enabled extensions, such as `asciidoctor-html5s`, `asciidoctor-bibtex`, or `asciidoctor-diagram`.
> [!note]
> To mitigate security risks, entries in the extension array may not contain forward slashes (`/`), backslashes (`\`), or periods. Due to this restriction, extensions must be in Ruby's `$LOAD_PATH`.
+6 -1
View File
@@ -10,6 +10,11 @@ This is the default configuration:
{{< code-toggle config=minify />}}
See the [tdewolff/minify] project page for details.
See the [tdewolff/minify] project page for details, but note the following:
- `css.inline` is for internal use. Changing this setting has no effect.
- `css.keepCSS2` has been deprecated. Use `css.version` instead.
- `html.keepConditionalComments` has been deprecated. Use `html.keepSpecialComments` instead.
- `svg.inline` is for internal use. Changing this setting has no effect.
[tdewolff/minify]: https://github.com/tdewolff/minify
+25 -21
View File
@@ -7,6 +7,8 @@ keywords: []
aliases: [/hugo-modules/configuration/]
---
{{% include "/_common/gomodules-info.md" %}}
## Top-level options
This is the default configuration:
@@ -40,7 +42,7 @@ proxy
: (`string`) The proxy server to use to download remote modules. Default is `direct`, which means `git clone` and similar.
replacements
: (`string`) Primarily useful for local module development, a comma-separated list of mappings from module paths to directories. Paths may be absolute or relative to the [`themesDir`].
: (`string`) Primarily useful for local module development, a comma-separated list of mappings from module paths to directories. Paths may be absolute or relative to the [`themesDir`][].
{{< code-toggle file=hugo >}}
[module]
@@ -61,8 +63,6 @@ export HUGO_MODULE_REPLACEMENTS="github.com/bep/my-theme -> ../.."
export HUGO_MODULE_WORKSPACE="/my/hugo.work"
```
{{% include "/_common/gomodules-info.md" %}}
## Hugo version
You can specify a required Hugo version for your module in the `module` section. Users will then receive a warning if their Hugo version is incompatible.
@@ -77,7 +77,7 @@ extended
: (`bool`) Whether the extended edition of Hugo is required, satisfied by installing either the extended or extended/deploy edition.
max
: (`string`) The maximum Hugo version supported, for example `0.148.0`.
: (`string`) The maximum Hugo version supported, for example `0.152.2`.
min
: (`string`) The minimum Hugo version supported, for example `0.102.0`.
@@ -110,32 +110,36 @@ noVendor
: (`bool`) Whether to disable vendoring for this import. This setting is restricted to the main project. Default is `false`.
path
: (`string`) The module path, either a valid Go module path (e.g., `github.com/gohugoio/myShortcodes`) or the directory name if stored in the [`themesDir`].
: (`string`) The module path, either a valid Go module path (e.g., `github.com/gohugoio/myShortcodes`) or the directory name if stored in the [`themesDir`][].
{{% include "/_common/gomodules-info.md" %}}
version
: {{< new-in 0.150.0 />}}
: If set to a [version query](https://go.dev/ref/mod#version-queries), this import becomes a direct dependency, in contrast to dependencies managed by Go Modules. See [this issue](https://github.com/gohugoio/hugo/pull/13966) for more information.
## Mounts
Before Hugo v0.56.0, custom component paths could only be configured by setting [`archetypeDir`], [`assetDir`], [`contentDir`], [`dataDir`], [`i18nDir`], [`layoutDi`], or [`staticDir`] in the site configuration. Module mounts offer greater flexibility than these legacy settings, but
you cannot use both.
{{% glossary-term mount %}}
[`archetypeDir`]: /configuration/all/
[`assetDir`]: /configuration/all/
[`contentDir`]: /configuration/all/
[`dataDir`]: /configuration/all/
[`i18nDir`]: /configuration/all/
[`layoutDi`]: /configuration/all/
[`staticDir`]: /configuration/all/
> [!important]
> If you define one or more mounts to map a file system path to a component path, do not use these legacy configuration settings: [`archetypeDir`][], [`assetDir`][], [`contentDir`][], [`dataDir`][], [`i18nDir`][], [`layoutDir`][], or [`staticDir`][].
> [!note]
> If you use module mounts do not use the legacy settings.
[`archetypeDir`]: /configuration/all/#archetypedir
[`assetDir`]: /configuration/all/#assetdir
[`contentDir`]: /configuration/all/#contentdir
[`dataDir`]: /configuration/all/#datadir
[`i18nDir`]: /configuration/all/#i18ndir
[`layoutDir`]: /configuration/all/#layoutdir
[`staticDir`]: /configuration/all/#staticdir
### Default mounts
> [!note]
> Adding a new mount to a target root will cause the existing default mount for that root to be ignored. If you still need the default mount, you must explicitly add it along with the new mount.
Within a project, if you define a mount to map a file system path to a component path, the corresponding default mount for that component will be removed. This action essentially overwrites the standard, automatic mapping for that specific component with your custom one.
The are the default mounts:
Within a module, if you define a mount to map a file system path to a component path, all of the default mounts will be removed. Defining a mount at the module level is a more sweeping change, causing all default mappings within that module to be discarded.
In either case, if you still need one of the default mounts, you must explicitly add it along with the new mount. Because custom mounts override defaults, any necessary default mappings must be re-added manually after you introduce your custom configuration.
These are the default mounts:
{{< code-toggle config=module.mounts />}}
@@ -143,7 +147,7 @@ source
: (`string`) The source directory of the mount. For the main project, this can be either project-relative or absolute. For other modules it must be project-relative.
target
: (`string`) Where the mount will reside within Hugo's virtual file system. It must begin with one of Hugo's component directories: `archetypes`, `assets`, `content`, `data`, `i18n`, `layouts`, or `static`. For example, `content/blog`.
: (`string`) Where the mount will reside within Hugo's [unified file system](g). It must begin with one of Hugo's [component](g) directories: archetypes, assets, content, data, i18n, layouts, or static. For example, content/blog.
disableWatch
: {{< new-in 0.128.0 />}}
+2 -2
View File
@@ -44,7 +44,7 @@ archetypes/
Hugo looks for archetypes in the `archetypes` directory in the root of your project, falling back to the `archetypes` directory in themes or installed modules. An archetype for a specific content type takes precedence over the default archetype.
For example, with this command:
For example, if you have enabled a theme named `my-theme` and you run this command:
```sh
hugo new content posts/my-first-post.md
@@ -53,8 +53,8 @@ hugo new content posts/my-first-post.md
The archetype lookup order is:
1. `archetypes/posts.md`
1. `archetypes/default.md`
1. `themes/my-theme/archetypes/posts.md`
1. `archetypes/default.md`
1. `themes/my-theme/archetypes/default.md`
If none of these exists, Hugo uses a built-in default archetype.
+1 -1
View File
@@ -256,5 +256,5 @@ Created from <https://arthursonzogni.com/Diagon/#Tree>
```
[code block render hook]: /render-hooks/code-blocks/
[embedded code block render hook]: {{% eturl render-codeblock-goat %}}
[embedded code block render hook]: <{{% eturl render-codeblock-goat %}}>
[GoAT]: https://github.com/bep/goat
@@ -47,7 +47,7 @@ build
: (`map`) A map of [build options].
cascade
: (`map`) 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 the [cascade] section for details.
: (`map`) A map (or a slice of maps) 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 the [cascade] section for details.
date
: (`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.
@@ -322,18 +322,18 @@ To override the default time zone, set the [`timeZone`](/configuration/all/#time
[`lastmod`]: /methods/page/date/
[`layout`]: /methods/page/layout/
[`linktitle`]: /methods/page/linktitle/
[`opengraph.html`]: {{% eturl opengraph %}}
[`opengraph.html`]: <{{% eturl opengraph %}}>
[`Param`]: /methods/page/param/
[`Params`]: /methods/page/params/
[`publishdate`]: /methods/page/publishdate/
[`readingtime`]: /methods/page/readingtime/
[`schema.html`]: {{% eturl schema %}}
[`schema.html`]: <{{% eturl schema %}}>
[`sitemap`]: /methods/page/sitemap/
[`slug`]: /methods/page/slug/
[`Summary`]: /methods/page/summary/
[`title`]: /methods/page/title/
[`translationkey`]: /methods/page/translationkey/
[`twitter_cards.html`]: {{% eturl twitter_cards %}}
[`twitter_cards.html`]: <{{% eturl twitter_cards %}}>
[`type`]: /methods/page/type/
[`weight`]: /methods/page/weight/
[`wordcount`]: /methods/page/wordcount/
@@ -105,8 +105,6 @@ The `image` resource implements the [`Process`], [`Resize`], [`Fit`], [`Fill`]
### Process
{{< new-in 0.119.0 />}}
> [!note]
> The `Process` method is also available as a filter, which is more effective if you need to apply multiple filters to an image. See [Process filter](/functions/images/process).
+27 -23
View File
@@ -6,13 +6,11 @@ categories: []
keywords: []
---
{{< new-in 0.122.0 />}}
## Overview
Mathematical equations and expressions written in [LaTeX] are common in academic and scientific publications. Your browser typically renders this mathematical markup using an open-source JavaScript display engine such as [MathJax] or [KaTeX].
Mathematical equations and expressions written in [LaTeX][] are common in academic and scientific publications. Your browser typically renders this mathematical markup using an open-source JavaScript display engine such as [MathJax][] or [KaTeX][].
For example, with this LaTeX markup:
For example, this LaTeX markup:
```text
\[
@@ -23,7 +21,7 @@ JS(\hat{y} || y) &= \frac{1}{2}(KL(y||\frac{y+\hat{y}}{2}) + KL(\hat{y}||\frac{y
\]
```
The MathJax display engine renders this:
Is rendered to:
\[
\begin{aligned}
@@ -37,7 +35,7 @@ Equations and expressions can be displayed inline with other text, or as standal
Whether an equation or expression appears inline, or as a block, depends on the delimiters that surround the mathematical markup. Delimiters are defined in pairs, where each pair consists of an opening and closing delimiter. The opening and closing delimiters may be the same, or different.
> [!note]
> You can configure Hugo to render mathematical markup on the client side using the MathJax or KaTeX display engine, or you can render the markup with the [`transform.ToMath`] function while building your site.
> You can configure Hugo to render mathematical markup on the client side using the MathJax or KaTeX display engine, or you can render the markup with the [`transform.ToMath`][] function while building your site.
>
> The first approach is described below.
@@ -46,7 +44,7 @@ Whether an equation or expression appears inline, or as a block, depends on the
Follow these instructions to include mathematical equations and expressions in your Markdown using LaTeX markup.
Step 1
: Enable and configure the Goldmark [passthrough extension] in your site configuration. The passthrough extension preserves raw Markdown within delimited snippets of text, including the delimiters themselves.
: Enable and configure the Goldmark [passthrough extension][] in your site configuration. The passthrough extension preserves raw Markdown within delimited snippets of text, including the delimiters themselves.
{{< code-toggle file=hugo copy=true >}}
[markup.goldmark.extensions.passthrough]
@@ -60,12 +58,12 @@ Step 1
math = true
{{< /code-toggle >}}
The configuration above enables mathematical rendering on every page unless you set the `math` parameter to `false` in front matter. To enable mathematical rendering as needed, set the `math` parameter to `false` in your site configuration, and set the `math` parameter to `true` in front matter. Use this parameter in your base template as shown in [Step 3](#step-3).
The configuration above enables mathematical rendering on every page unless you set the `math` parameter to `false` in front matter. To enable mathematical rendering as needed, set the `math` parameter to `false` in your site configuration, and set the `math` parameter to `true` in front matter. Use this parameter in your base template as shown in [Step 3][].
> [!note]
> The configuration above precludes the use of the `$...$` delimiter pair for inline equations. Although you can add this delimiter pair to the configuration and JavaScript, you must double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting.
>
> See the [inline delimiters](#inline-delimiters) section for details.
> See the [inline delimiters][] section for details.
To disable passthrough of inline snippets, omit the `inline` key from the configuration:
@@ -74,7 +72,7 @@ Step 1
block = [['\[', '\]'], ['$$', '$$']]
{{< /code-toggle >}}
You can define your own opening and closing delimiters, provided they match the delimiters that you set in [Step 2].
You can define your own opening and closing delimiters, provided they match the delimiters that you set in [Step 2][].
{{< code-toggle file=hugo >}}
[markup.goldmark.extensions.passthrough.delimiters]
@@ -83,10 +81,11 @@ Step 1
{{< /code-toggle >}}
Step 2
: Create a _partial_ template to load MathJax or KaTeX. The example below loads MathJax, or you can use KaTeX as described in the [engines](#engines) section.
: Create a _partial_ template to load MathJax or KaTeX. The example below loads MathJax, or you can use KaTeX as described in the [engines][] section.
```go-html-template {file="layouts/_partials/math.html" copy=true}
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js"></script>
<script>
MathJax = {
tex: {
@@ -165,35 +164,35 @@ I will give you \\$2 if you can solve $y = x^2$.
```
> [!note]
> If you use the `$...$` delimiter pair for inline equations, and occasionally use the&nbsp;`$`&nbsp;symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation](https://github.com/KaTeX/KaTeX/issues/437).
> If you use the `$...$` delimiter pair for inline equations, and occasionally use the&nbsp;`$`&nbsp;symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation][].
## Engines
MathJax and KaTeX are open-source JavaScript display engines. Both engines are fast, but at the time of this writing MathJax v3.2.2 is slightly faster than KaTeX v0.16.11.
MathJax and KaTeX are open-source JavaScript display engines.
> [!note]
> If you use the `$...$` delimiter pair for inline equations, and occasionally use the&nbsp;`$`&nbsp;symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation](https://github.com/KaTeX/KaTeX/issues/437).
> If you use the `$...$` delimiter pair for inline equations, and occasionally use the&nbsp;`$`&nbsp;symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation][].
>
>See the [inline delimiters](#inline-delimiters) section for details.
>See the [inline delimiters][] section for details.
To use KaTeX instead of MathJax, replace the _partial_ template from [Step 2] with this:
To use KaTeX instead of MathJax, replace the _partial_ template from [Step 2][] with this:
```go-html-template {file="layouts/_partials/math.html" copy=true}
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css"
integrity="sha384-zh0CIslj+VczCZtlzBcjt5ppRcsAmDnRem7ESsYwWwg3m/OaJ2l4x7YBZl9Kxxib"
href="https://cdn.jsdelivr.net/npm/katex@0.16.25/dist/katex.min.css"
integrity="sha384-WcoG4HRXMzYzfCgiyfrySxx90XSl2rxY5mnVY5TwtWE6KLrArNKn0T/mOgNL0Mmi"
crossorigin="anonymous"
>
<script
defer
src="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.js"
integrity="sha384-Rma6DA2IPUwhNxmrB/7S3Tno0YY7sFu9WSYMCuulLhIqYSGZ2gKCJWIqhBWqMQfh"
src="https://cdn.jsdelivr.net/npm/katex@0.16.25/dist/katex.min.js"
integrity="sha384-J+9dG2KMoiR9hqcFao0IBLwxt6zpcyN68IgwzsCSkbreXUjmNVRhPFTssqdSGjwQ"
crossorigin="anonymous">
</script>
<script
defer
src="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/contrib/auto-render.min.js"
src="https://cdn.jsdelivr.net/npm/katex@0.16.25/dist/contrib/auto-render.min.js"
integrity="sha384-hCXGrW6PitJEwbkoStFjeJxv+fSOOQKOPbJxSfM6G5sWZjAyWhXiTIIAmQqnlLlh"
crossorigin="anonymous"
onload="renderMathInElement(document.body);">
@@ -224,10 +223,15 @@ $$C_p[\ce{H2O(l)}] = \pu{75.3 J // mol K}$$
$$C_p[\ce{H2O(l)}] = \pu{75.3 J // mol K}$$
As shown in [Step 2](#step-2) above, MathJax supports chemical equations without additional configuration. To add chemistry support to KaTeX, enable the mhchem extension as described in the KaTeX [documentation](https://katex.org/docs/libs).
As shown in [Step 2][] above, MathJax supports chemical equations without additional configuration. To add chemistry support to KaTeX, enable the mhchem extension as described in the KaTeX [documentation](https://katex.org/docs/libs).
[`transform.ToMath`]: /functions/transform/tomath/
[engines]: #engines
[inline delimiters]: #inline-delimiters
[KaTeX]: https://katex.org/
[LaTeX]: https://www.latex-project.org/
[MathJax]: https://www.mathjax.org/
[passthrough extension]: /configuration/markup/#passthrough
[Step 2]: #step-2
[Step 3]: #step-3
[this KaTeX limitation]: https://github.com/KaTeX/KaTeX/issues/437
@@ -9,7 +9,7 @@ aliases: [/content/sections/]
## Page bundles
Hugo `0.32` announced page-relative images and other resources packaged into `Page Bundles`.
Hugo supports page-relative images and other resources packaged into `Page Bundles`.
These terms are connected, and you also need to read about [Page Resources](/content-management/page-resources) and [Image Processing](/content-management/image-processing) to get the full picture.
@@ -33,6 +33,35 @@ This is the first paragraph.
This is the second paragraph.
```
> [!NOTE]
> Place the summary divider on its own line. Do not place it inline with other content.
Correct placement:
```text {file="content/example.md"}
---
title: 'Example'
---
This is an example of **strong text** in a sentence. This is another sentence.
<!--more-->
This is another paragraph.
```
Incorrect placement:
```text {file="content/example.md"}
---
title: 'Example'
---
This is an example of **strong text** <!--more--> in a sentence. This is another sentence.
This is another paragraph.
```
When using the Emacs Org Mode [content format], use a `# more` divider to indicate the end of the summary.
[content format]: /content-management/formats/
@@ -79,6 +108,9 @@ For example, with a `summaryLength` of 7, the automatic summary will be:
<p>This is the second paragraph.</p>
```
> [!warning]
> Automatic `.Summary` may cut block tags (e.g., `blockquote`) in the middle when `summaryLength` is reached, causing the browser to recover the end tag (the end tag will be inserted before the parent's end tag), resulting in unexpected rendering behavior. To avoid this, wrap `.Summary` in a `<div>`; alternatively, wrap it together with the heading tag using `<section>`. You can avoid this entirely by using a manual summary. See issue [#14044] for details.
## Comparison
Each summary type has different characteristics:
@@ -121,3 +153,5 @@ Instead of calling the `Summary` method on a `Page` object, use the [`strings.Tr
</div>
{{ end }}
```
[#14044]: https://github.com/gohugoio/hugo/issues/14044
+9 -12
View File
@@ -90,23 +90,20 @@ tags = ['Tag A','Tag B']
categories = ['Category A','Category B']
{{< /code-toggle >}}
## Order taxonomies
## Taxonomic 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 templates and is declared in a content file's front matter. The convention for declaring taxonomic weight is `taxonomyname_weight`.
{{% glossary-term "taxonomic weight" %}}
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.
Assign a taxonomic weight using a front matter key named `[taxonomy_name]_weight`.
### Example: taxonomic `weight`
{{< code-toggle file=hugo >}}
title = "foo"
tags = [ "a", "b", "c" ]
tags_weight = 22
categories = ["d"]
categories_weight = 44
{{< code-toggle file="content/courses/organic-chemistry.md" fm=true >}}
title = 'Organic Chemistry'
weight = 10
tags_weight = 1000
tags = ['chemistry','science']
{{</ code-toggle >}}
By using taxonomic weight, the same piece of content can appear in different positions in different taxonomies.
With the front matter above, the "Organic Chemistry" page will float towards the top of the list on section and home pages, and it will sink towards the bottom of the list on the "chemistry" and "science" term pages.
## Metadata
+3 -6
View File
@@ -235,18 +235,15 @@ The alias from the previous URL to the new URL is a client-side redirect:
<head>
<title>https://example.org/posts/new-file-name/</title>
<link rel="canonical" href="https://example.org/posts/new-file-name/">
<meta name="robots" content="noindex">
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=https://example.org/posts/new-file-name/">
</head>
</html>
```
Collectively, the elements in the `head` section:
The `link rel="canonical"` tag informs search engines that the new URL is the preferred or "canonical" version of the page. This is crucial for SEO, as it prevents issues with duplicate content by consolidating all ranking signals to a single URL.
- Tell search engines that the new URL is canonical
- Tell search engines not to index the previous URL
- Tell the browser to redirect to the new URL
The `http-equiv="refresh"` meta tag instructs the web browser to automatically redirect the user to the new URL. This ensures that anyone who accesses the old alias URL is seamlessly taken to the correct, updated page.
Hugo renders alias files before rendering pages. A new page with the previous file name will overwrite the alias, as expected.
@@ -263,4 +260,4 @@ Page
[`baseURL`]: /configuration/all/#baseurl
[removed in a future release]: https://github.com/gohugoio/hugo/issues/4733
[reserved characters]: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
[source code]: {{% eturl alias %}}
[source code]: <{{% eturl alias %}}>
+3 -3
View File
@@ -32,7 +32,7 @@ For a complete guide to contributing to Hugo, see the [Contribution Guide].
To build the extended or extended/deploy edition from source you must:
1. Install [Git]
1. Install [Go] version 1.23.0 or later
1. Install [Go] version 1.24.0 or later
1. Install a C compiler, either [GCC] or [Clang]
1. Update your `PATH` environment variable as described in the [Go documentation]
@@ -102,7 +102,7 @@ Step 7
: Commit your changes with a descriptive commit message:
- Provide a summary on the first line, typically 50 characters or less, followed by a blank line.
- Begin the summary with one of content, theme, config, all, or misc, followed by a colon, a space, and a brief description of the change beginning with a capital letter
- Begin the summary with the name of the package, followed by a colon, a space, and a brief description of the change beginning with a capital letter
- Use imperative present tense
- See the [commit message guidelines] for requirements
- Optionally, provide a detailed description where each line is 72 characters or less, followed by a blank line.
@@ -143,7 +143,7 @@ CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
To build and install a specific release:
```sh
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.148.0
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.152.2
```
To build and install at the latest commit on the master branch:
+23 -2
View File
@@ -24,7 +24,15 @@ Follow Google's [developer documentation style guide].
Adhere to these Markdown conventions:
- Use [ATX] headings (levels 2-4), not [setext] headings.
- Use [fenced code blocks], not [indented code blocks].
- Use [collapsed link references][] instead of full or shortcut references. For example:
```text
This is a [link][].
[link]: https://example.org
```
- Use [fenced code blocks] instead of [indented code blocks].
- Use hyphens, not asterisks, for unordered [list items].
- Use [callouts](#callouts) instead of bold text for emphasis.
- Do not mix [raw HTML] within Markdown.
@@ -260,6 +268,18 @@ To wrap the code block within an initially-opened `details` element using a non-
```
````
Whitespace trimming is enabled by default. To override this behavior and preserve leading and trailing spaces:
````text
```go-html-template {trim=false}
{{ if eq $foo "bar" }}
{{ print "foo is bar" }}
{{ end }}
```
````
### Shortcode calls
Use this syntax :
@@ -399,7 +419,7 @@ Use the embedded template URL (`eturl`) shortcode to insert an absolute URL to t
```text
This is a link to the [embedded alias template].
[embedded alias template]: {{%/* eturl alias */%}}
[embedded alias template]: <{{%/* eturl alias */%}}>
```
### glossary-term
@@ -522,6 +542,7 @@ Step 9
[ATX]: https://spec.commonmark.org/current/#atx-headings
[basic english]: https://simple.wikipedia.org/wiki/Basic_English
[collapsed link references]: https://discourse.gohugo.io/t/55714
[developer documentation style guide]: https://developers.google.com/style
[documentation repository]: https://github.com/gohugoio/hugoDocs/
[fenced code blocks]: https://spec.commonmark.org/current/#fenced-code-blocks
+64
View File
@@ -0,0 +1,64 @@
---
title: collections.D
description: Returns a slice of sequentially ordered random integers.
categories: []
keywords: [random]
params:
functions_and_methods:
returnType: '[]int'
signatures: [collections.D SEED N HIGH]
---
{{< new-in 0.149.0 />}}
The `collections.D` function returns a slice of `N` sequentially ordered unique random integers in the half-open [interval](g) [0, `HIGH`) using the provided [`SEED`](g) value. This function implements J. S. Vitter's Method&nbsp;D[^1] for sequential random sampling, a fast and efficient algorithm for this task.
See [this article][] for a detailed explanation.
## Examples
```go-html-template
{{ collections.D 6 7 42 }} → [4, 9, 10, 20, 22, 24, 41]
```
The example above generates the _same_ random numbers each time it is called. To generate a _different_ set of 7 random numbers in the same range, change the seed value.
```go-html-template
{{ collections.D 2 7 42 }} → [3, 11, 19, 25, 32, 33, 38]
```
A common use case is the selection of random pages from a page collection. For example, to render a list of 5 random pages using the [day of the year][] as the seed value:
```go-html-template
<ul>
{{ $p := site.RegularPages }}
{{ range collections.D time.Now.YearDay 5 ($p | len) }}
{{ with (index $p .) }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
{{ end }}
</ul>
```
The construct above is significantly faster than using the [`collections.Shuffle`][] function.
## Seed value
Choosing an appropriate seed value depends on your objective.
Objective|Seed example
:--|:--
Consistent result|`42`
Different result on each call|`int time.Now.UnixNano`
Same result per day|`time.Now.YearDay`
Same result per page|`hash.FNV32a .Path`
Different result per page per day|`hash.FNV32a (print .Path time.Now.YearDay)`
> [!note]
> The slice created by this function is limited to 1 million elements.
[^1]: J. S. Vitter, "An efficient algorithm for sequential random sampling," _ACM Trans. Math. Soft._, vol. 13, pp. 58&ndash;67, Mar. 1987.
[`collections.Shuffle`]: /functions/collections/shuffle/
[day of the year]: /methods/time/yearday/
[this article]: https://getkerf.wordpress.com/2016/03/30/the-best-algorithm-no-one-knows-about/
+24 -2
View File
@@ -11,19 +11,41 @@ params:
aliases: [/functions/first]
---
```go-html-template
{{ slice "a" "b" "c" | first 1 }} → [a]
{{ slice "a" "b" "c" | first 2 }} → [a b]
```
Given that a string is in effect a read-only slice of bytes, this function can be used to return the specified number of bytes from the beginning of the string:
```go-html-template
{{ "abc" | first 1 }} → a
{{ "abc" | first 2 }} → ab
```
Note that a _character_ may consist of multiple _bytes_:
```go-html-template
{{ "Schön" | first 3 }} → Sch
{{ "Schön" | first 4 }} → Sch\xc3
{{ "Schön" | first 5 }} → Schö
```
To use the `collections.First` function with a page collection:
```go-html-template
{{ range first 5 .Pages }}
{{ .Render "summary" }}
{{ end }}
```
Set `N` to zero to return an empty collection.
Set `N` to zero to return an empty collection:
```go-html-template
{{ $emptyPageCollection := first 0 .Pages }}
```
Use `first` and [`where`] together.
Use `first` and [`where`][] together:
```go-html-template
{{ range where .Pages "Section" "articles" | first 5 }}
+1 -1
View File
@@ -18,7 +18,7 @@ For example, consider this site configuration:
showHeroImage = false
{{< /code-toggle >}}
It the value of `showHeroImage` is `true`, we can detect that it exists using either `if` or `with`:
If the value of `showHeroImage` is `true`, we can detect that it exists using either `if` or `with`:
```go-html-template
{{ if site.Params.showHeroImage }}
+25 -3
View File
@@ -12,18 +12,40 @@ aliases: [/functions/last]
---
```go-html-template
{{ range last 10 .Pages }}
{{ slice "a" "b" "c" | last 1 }} → [c]
{{ slice "a" "b" "c" | last 2 }} → [b c]
```
Given that a string is in effect a read-only slice of bytes, this function can be used to return the specified number of bytes from the end of the string:
```go-html-template
{{ "abc" | last 1 }} → c
{{ "abc" | last 2 }} → bc
```
Note that a _character_ may consist of multiple _bytes_:
```go-html-template
{{ "Schön" | last 1 }} → n
{{ "Schön" | last 2 }} → \xb6n
{{ "Schön" | last 3 }} → ön
```
To use the `collections.Last` function with a page collection:
```go-html-template
{{ range last 5 .Pages }}
{{ .Render "summary" }}
{{ end }}
```
Set `N` to zero to return an empty collection.
Set `N` to zero to return an empty collection:
```go-html-template
{{ $emptyPageCollection := last 0 .Pages }}
```
Use `last` and [`where`] together.
Use `last` and [`where`][] together:
[`where`]: /functions/collections/where/
+1 -1
View File
@@ -32,4 +32,4 @@ A contrived example of iterating over a sequence of integers:
```
> [!note]
> The slice created by the `seq` function is limited to 2000 elements.
> The slice created by this function is limited to 1 million elements.
+7 -1
View File
@@ -2,7 +2,7 @@
title: collections.Shuffle
description: Returns a random permutation of a given array or slice.
categories: []
keywords: []
keywords: [random]
params:
functions_and_methods:
aliases: [shuffle]
@@ -27,3 +27,9 @@ To render an unordered list of 5 random pages from a page collection:
{{ end }}
</ul>
```
{{< new-in 0.149.0 />}}
Using the [`collections.D`][] function for the same task is significantly faster.
[`collections.D`]: /functions/collections/D/
+1 -1
View File
@@ -41,7 +41,7 @@ The `default` function returns the first argument if the second argument is not
{{ default 42 "" }} → 42
{{ default 42 dict }} → 42
{{ default 42 slice }} → 42
{{ default 42 <nil> }} → 42
{{ default 42 nil }} → 42
```
[`or`]: /functions/go-template/or/
+73
View File
@@ -0,0 +1,73 @@
---
title: css.Quoted
description: Returns the given string, setting its data type to indicate that it must be quoted when used in CSS.
categories: []
keywords: []
params:
functions_and_methods:
aliases: []
returnType: css.QuotedString
signatures: [css.Quoted STRING]
---
<!-- Added in v0.111.0 -->
> [!note]
> This function is only applicable to the [`vars`] option passed to the [`css.Sass`] function.
When when passing a `vars` map to the `css.Sass` function, Hugo detects common typed CSS values such as `24px` or `#FF0000` using regular expression matching. If necessary, you can bypass automatic type inference by using the `css.Quoted` function to explicitly indicate that the value must be treated as a quoted string.
For example:
```scss {file="assets/sass/main.scss"}
@use "hugo:vars" as h;
ol li::after {
content: h.$ol-li-after;
}
ul li::after {
content: h.$ul-li-after;
}
```
```go-html-template {file="layouts/_partials/css.html"}
{{ $vars := dict
"ol_li_after" ("6" | css.Quoted )
"ul_li_after" ("7" | css.Quoted )
}}
{{ with resources.Get "sass/main.scss" }}
{{ $opts := dict
"enableSourceMap" hugo.IsDevelopment
"outputStyle" (cond hugo.IsDevelopment "expanded" "compressed")
"targetPath" "css/main.css"
"transpiler" "dartsass"
"vars" $vars
}}
{{ with . | toCSS $opts }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ end }}
{{ end }}
{{ end }}
```
The Sass code is transpiled to:
```css {file="public/css/main.css"}
ol li::after {
content: "6";
}
ul li::after {
content: "7";
}
```
[`css.Sass`]: /functions/css/sass/
[`vars`]: /functions/css/sass/#vars
+22 -15
View File
@@ -14,10 +14,7 @@ params:
Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended and extended/deploy editions, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language.
Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both.
[scss]: https://sass-lang.com/documentation/syntax#scss
[indented]: https://sass-lang.com/documentation/syntax#the-indented-syntax
Sass has two forms of syntax: [SCSS][] and [indented][]. Hugo supports both.
## Options
@@ -45,7 +42,7 @@ sourceMapIncludeSources
: (`bool`) Whether to embed sources in the generated source map. Applicable to Dart Sass. Default is `false`.
targetPath
: (`string`) The publish path for the transformed resource, relative to the[`publishDir`]. If unset, the target path defaults to the asset's original path with a `.css` extension.
: (`string`) The publish path for the transformed resource, relative to the[`publishDir`][]. If unset, the target path defaults to the asset's original path with a `.css` extension.
transpiler
: (`string`) The transpiler to use, either `libsass` or `dartsass`. Hugo's extended and extended/deploy editions include the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass). Default is `libsass`.
@@ -61,6 +58,8 @@ vars
@use "hugo:vars" as v;
```
When when passing a `vars` map to the `css.Sass` function, Hugo detects common typed CSS values such as `24px` or `#FF0000` using regular expression matching. If necessary, you can bypass automatic type inference by using the [`css.Quoted`][] or [`css.Unquoted`][] function to explicitly indicate a value's type.
## Example
```go-html-template {copy=true}
@@ -87,7 +86,7 @@ vars
## Dart Sass
Hugo's extended and extended/deploy editions include [LibSass] to transpile Sass to CSS. In 2020, the Sass team deprecated LibSass in favor of [Dart Sass].
Hugo's extended and extended/deploy editions include [LibSass][] to transpile Sass to CSS. In 2020, the Sass team deprecated LibSass in favor of [Dart Sass].
Use the latest features of the Sass language by installing Dart Sass in your development and production environments.
@@ -113,7 +112,7 @@ macOS|Homebrew|[brew.sh]|`brew install sass/sass/sass`
Windows|Chocolatey|[chocolatey.org]|`choco install sass`
Windows|Scoop|[scoop.sh]|`scoop install sass`
You may also install [prebuilt binaries] for Linux, macOS, and Windows. You must install the prebuilt binary outside of your project directory and ensure its path is included in your system's PATH environment variable.
You may also install [prebuilt binaries][] for Linux, macOS, and Windows. You must install the prebuilt binary outside of your project directory and ensure its path is included in your system's PATH environment variable.
Run `hugo env` to list the active transpilers.
@@ -127,26 +126,34 @@ To use Dart Sass with Hugo on a CI/CD platform like GitHub Pages, GitLab Pages,
There's one key exception where you can skip this step: you have committed your `resources` directory to your repository. This is only possible if:
- You have not changed Hugo's default asset cache location.
- You have not set [`useResourceCacheWhen`] to never in your sites configuration.
- You have not set [`useResourceCacheWhen`][] to never in your sites configuration.
By committing the `resources` directory, you're providing the pre-built CSS files directly to your CI/CD service, so it doesn't need to run the Sass compilation itself.
For examples of how to install Dart Sass in a production environment, see the following workflow files:
For examples of how to install Dart Sass in a production environment, see these hosting guides:
- [Cloudflare]
- [GitHub Pages]
- [GitLab Pages]
- [Netlify]
- [Render]
- [Vercel]
[`css.Quoted`]: /functions/css/quoted/
[`css.Unquoted`]: /functions/css/unquoted/
[`publishDir`]: /configuration/all/#publishdir
[`useResourceCacheWhen`]: /configuration/build/#useresourcecachewhen
[brew.sh]: https://brew.sh/
[chocolatey.org]: https://community.chocolatey.org/packages/sass
[dart sass]: https://sass-lang.com/dart-sass
[GitHub Pages]: /host-and-deploy/host-on-github-pages/#step-7
[GitLab Pages]: /host-and-deploy/host-on-gitlab-pages/#configure-gitlab-cicd
[libsass]: https://sass-lang.com/libsass
[Netlify]: /host-and-deploy/host-on-netlify/#configuration-file
[Cloudflare]: /host-and-deploy/host-on-cloudflare/
[GitHub Pages]: /host-and-deploy/host-on-github-pages/
[GitLab Pages]: /host-and-deploy/host-on-gitlab-pages/
[indented]: https://sass-lang.com/documentation/syntax#the-indented-syntax
[LibSass]: https://sass-lang.com/libsass
[Netlify]: /host-and-deploy/host-on-netlify/
[prebuilt binaries]: https://github.com/sass/dart-sass/releases/latest
[Render]: /host-and-deploy/host-on-render/
[scoop.sh]: https://scoop.sh/#/apps?q=sass
[snap package]: /installation/linux/#snap
[SCSS]: https://sass-lang.com/documentation/syntax#scss
[snapcraft.io]: https://snapcraft.io/dart-sass
[Vercel]: /host-and-deploy/host-on-vercel/
+73
View File
@@ -0,0 +1,73 @@
---
title: css.Unquoted
description: Returns the given string, setting its data type to indicate that it must not be quoted when used in CSS.
categories: []
keywords: []
params:
functions_and_methods:
aliases: []
returnType: css.UnquotedString
signatures: [css.Unquoted STRING]
---
<!-- Added in v0.111.0 -->
> [!note]
> This function is only applicable to the [`vars`] option passed to the [`css.Sass`] function.
When when passing a `vars` map to the `css.Sass` function, Hugo detects common typed CSS values such as `24px` or `#FF0000` using regular expression matching. If necessary, you can bypass automatic type inference by using the `css.Unquoted` function to explicitly indicate that the value must not be treated as a quoted string.
For example:
```scss {file="assets/sass/main.scss"}
@use "hugo:vars" as h;
h1 {
font-size: h.$font-size-h1;
}
h2 {
font-size: h.$font-size-h2;
}
```
```go-html-template {file="layouts/_partials/css.html"}
{{ $vars := dict
"font_size_h1" ("72px * 0.500" | css.Unquoted)
"font_size_h2" ("72px * 0.375" | css.Unquoted)
}}
{{ with resources.Get "sass/main.scss" }}
{{ $opts := dict
"enableSourceMap" hugo.IsDevelopment
"outputStyle" (cond hugo.IsDevelopment "expanded" "compressed")
"targetPath" "css/main.css"
"transpiler" "dartsass"
"vars" $vars
}}
{{ with . | toCSS $opts }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ end }}
{{ end }}
{{ end }}
```
The Sass rules are transpiled to:
```css {file="public/css/main.css"}
h1 {
font-size: 36px;
}
h2 {
font-size: 27px;
}
```
[`css.Sass`]: /functions/css/sass/
[`vars`]: /functions/css/sass/#vars
-2
View File
@@ -10,8 +10,6 @@ params:
signatures: [debug.Timer NAME]
---
{{< new-in 0.120.0 />}}
Use the `debug.Timer` function to determine execution time for a block of code, useful for finding performance bottlenecks in templates.
The timer starts when you instantiate it, and stops when you call its `Stop` method.
@@ -0,0 +1,17 @@
---
title: debug.VisualizeSpaces
description: Returns the given string with spaces replaced by a visible string.
categories: []
keywords: []
params:
functions_and_methods:
aliases: []
returnType: string
signatures: [debug.VisualizeSpaces STRING]
---
<!-- Added in v0.112.0 -->
```go-html-template
{{ debug.VisualizeSpaces "foo bar" }} → foo[SPACE][SPACE]bar
```
+1 -1
View File
@@ -111,5 +111,5 @@ svg.foo {
```
[code block render hook]: /render-hooks/code-blocks/
[embedded code block render hook]: {{% eturl render-codeblock-goat %}}
[embedded code block render hook]: <{{% eturl render-codeblock-goat %}}>
[GoAT]: https://github.com/bep/goat
+1
View File
@@ -13,4 +13,5 @@ aliases: [/functions/println]
```go-html-template
{{ println "foo" }} → foo\n
{{ println "foo" "bar" }} → foo bar\n
```
+1 -1
View File
@@ -11,5 +11,5 @@ params:
---
```go-html-template
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.148.0">
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.152.2">
```
@@ -10,8 +10,6 @@ params:
signatures: [hugo.IsDevelopment]
---
{{< new-in 0.120.0 />}}
```go-html-template
{{ hugo.IsDevelopment }} → true/false
```
-2
View File
@@ -10,8 +10,6 @@ params:
signatures: [hugo.IsServer]
---
{{< new-in 0.120.0 />}}
```go-html-template
{{ hugo.IsServer }} → true/false
```
+1 -1
View File
@@ -11,5 +11,5 @@ params:
---
```go-html-template
{{ hugo.Version }} → 0.148.0
{{ hugo.Version }} → 0.152.2
```
@@ -10,8 +10,6 @@ params:
signatures: [images.AutoOrient]
---
{{< new-in 0.121.2 />}}
## Usage
Create the filter:
-2
View File
@@ -10,8 +10,6 @@ params:
signatures: [images.Opacity OPACITY]
---
{{< new-in 0.119.0 />}}
The opacity value must be in the range [0, 1]. A value of `0` produces a transparent image, and a value of `1` produces an opaque image (no transparency).
## Usage
-2
View File
@@ -10,8 +10,6 @@ params:
signatures: ['images.Padding V1 [V2] [V3] [V4] [COLOR]']
---
{{< new-in 0.120.0 />}}
The last argument is the canvas color, expressed as an RGB or RGBA [hexadecimal color]. The default value is `ffffffff` (opaque white). The preceding arguments are the padding values, in pixels, using the CSS [shorthand property] syntax. Negative padding values will crop the image.
[hexadecimal color]: https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color
-2
View File
@@ -10,8 +10,6 @@ params:
signatures: [images.Process SPEC]
---
{{< new-in 0.119.0 />}}
This filter has the same options as the [`Process`] method on a `Resource` object, but using it as a filter may be more effective if you need to apply multiple filters to an image.
[`Process`]: /methods/resource/process/
+4 -2
View File
@@ -150,8 +150,8 @@ 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:
- `targetPath` is set automatically (there may be multiple outputs).
- ``format` must be `esm`, currently the only format supporting [code splitting].
- ``params` will be available in the `@params/config` namespace in the scripts. This way you can import both the [script] or [runner] params and the [config] params with:
- `format` must be `esm`, currently the only format supporting [code splitting].
- `params` will be available in the `@params/config` namespace in the scripts. This way you can import both the [script] or [runner] params and the [config] params with:
```js
import * as params from "@params";
@@ -295,6 +295,8 @@ console.log('entrypoints-workaround.js');
[code splitting]: https://esbuild.github.io/api/#splitting
[config]: #config
[ESBuild]: https://github.com/evanw/esbuild
[group]: #group
[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/
[OptionsSetter]: #optionssetter
+14 -15
View File
@@ -13,27 +13,27 @@ aliases: [/functions/i18n]
The `lang.Translate` function returns the value associated with given key as defined in the translation table for the current language.
If the key is not found in the translation table for the current language, the `lang.Translate` function falls back to the translation table for the [`defaultContentLanguage`].
If the key is not found in the translation table for the current language, the `lang.Translate` function falls back to the translation table for the [`defaultContentLanguage`][].
If the key is not found in the translation table for the `defaultContentLanguage`, the `lang.Translate` function returns an empty string.
> [!note]
> To list missing and fallback translations, use the `--printI18nWarnings` flag when building your site.
>
> To render placeholders for missing and fallback translations, set [`enableMissingTranslationPlaceholders`] to `true` in your site configuration.
> To render placeholders for missing and fallback translations, set [`enableMissingTranslationPlaceholders`][] to `true` in your site configuration.
## Translation tables
Create translation tables in the `i18n` directory, naming each file according to [RFC 5646]. Translation tables may be JSON, TOML, or YAML. For example:
Create translation tables in the `i18n` directory, naming each file according to [RFC 5646][]. Translation tables may be JSON, TOML, or YAML. For example:
```text
i18n/en.toml
i18n/en-US.toml
```
The base name must match the [language key] as defined in your site configuration.
The base name must match the [language key][] as defined in your site configuration.
Artificial languages with private use subtags as defined in [RFC 5646 § 2.2.7] are also supported. You may omit the `art-x-` prefix for brevity. For example:
Artificial languages with private use subtags as defined in [RFC 5646 § 2.2.7][] are also supported. You may omit the `art-x-` prefix for brevity. For example:
```text
i18n/art-x-hugolang.toml
@@ -94,7 +94,7 @@ i18n/
└── pl.toml
```
The Unicode [CLDR Plural Rules chart] describes the pluralization categories for each language.
The Unicode [CLDR Plural Rules chart][CLDR] describes the pluralization categories for each language.
The English translation table:
@@ -177,7 +177,7 @@ Template code:
## Reserved keys
Hugo uses the [go-i18n] package to look up values in translation tables. This package reserves the following keys for internal use:
Hugo uses the [go-i18n][] package to look up values in translation tables. This package reserves the following keys for internal use:
id
: (`string`) Uniquely identifies the message.
@@ -195,22 +195,22 @@ rightdelim
: (`string`) The right Go template delimiter.
zero
: (`string`) The content of the message for the [CLDR] plural form "zero".
: (`string`) The content of the message for the [CLDR][] plural form "zero".
one
: (`string`) The content of the message for the [CLDR] plural form "one".
: (`string`) The content of the message for the [CLDR][] plural form "one".
two
: (`string`) The content of the message for the [CLDR] plural form "two".
: (`string`) The content of the message for the [CLDR][] plural form "two".
few
: (`string`) The content of the message for the [CLDR] plural form "few".
: (`string`) The content of the message for the [CLDR][] plural form "few".
many
: (`string`) The content of the message for the [CLDR] plural form "many".
: (`string`) The content of the message for the [CLDR][] plural form "many".
other
: (`string`) The content of the message for the [CLDR] plural form "other".
: (`string`) The content of the message for the [CLDR][] plural form "other".
If you need to provide a translation for one of the reserved keys, you can prepend the word with an underscore. For example:
@@ -238,8 +238,7 @@ Then in your templates:
[`defaultContentLanguage`]: /configuration/all/#defaultcontentlanguage
[`enableMissingTranslationPlaceholders`]: /configuration/all/#enablemissingtranslationplaceholders
[CLDR]: https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html
[CLDR Plural Rules chart]: https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html
[CLDR]: https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
[go-i18n]: https://github.com/nicksnyder/go-i18n
[language key]: /configuration/languages/#language-keys
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646
+1 -3
View File
@@ -2,7 +2,7 @@
title: math.Rand
description: Returns a pseudo-random number in the half-open interval [0.0, 1.0).
categories: []
keywords: []
keywords: [random]
params:
functions_and_methods:
aliases: []
@@ -10,8 +10,6 @@ params:
signatures: [math.Rand]
---
{{< new-in 0.121.2 />}}
The `math.Rand` function returns a pseudo-random number in the half-open [interval](g) [0.0, 1.0).
```go-html-template
@@ -1,6 +1,6 @@
---
title: partials.IncludeCached
description: Executes the given template and caches the result, optionally passing context. If the partial template contains a return statement, returns the given value, else returns the rendered output.
description: Executes the given template and caches the result, optionally passing one or more variant keys. If the partial template contains a return statement, returns the given value, else returns the rendered output.
categories: []
keywords: []
params:
+1 -1
View File
@@ -23,7 +23,7 @@ Let's say you need to publish a file named "site.json" in the root of your `publ
```json
{
"build_date": "2025-07-08T13:12:19-07:00",
"hugo_version": "0.148.0",
"hugo_version": "0.152.2",
"last_modified": "2025-07-07T22:09:13-07:00"
}
```
+1 -1
View File
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: [countrunes]
returnType: int
signatures: [strings.CountRunes INPUT]
signatures: [strings.CountRunes STRING]
aliases: [/functions/countrunes]
---
+1 -1
View File
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: [countwords]
returnType: int
signatures: [strings.CountWords INPUT]
signatures: [strings.CountWords STRING]
aliases: [/functions/countwords]
---
+1 -1
View File
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: []
returnType: string
signatures: [strings.Repeat COUNT INPUT]
signatures: [strings.Repeat COUNT STRING]
aliases: [/functions/strings.repeat]
---
+1 -1
View File
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: []
returnType: int
signatures: [strings.RuneCount INPUT]
signatures: [strings.RuneCount STRING]
aliases: [/functions/strings.runecount]
---
+1 -1
View File
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: [lower]
returnType: string
signatures: [strings.ToLower INPUT]
signatures: [strings.ToLower STRING]
aliases: [/functions/lower]
---
+1 -1
View File
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: [upper]
returnType: string
signatures: [strings.ToUpper INPUT]
signatures: [strings.ToUpper STRING]
aliases: [/functions/upper]
---
+1 -1
View File
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: [trim]
returnType: string
signatures: [strings.Trim INPUT CUTSET]
signatures: [strings.Trim STRING CUTSET]
aliases: [/functions/trim]
---
+1 -1
View File
@@ -6,7 +6,7 @@ keywords: []
params:
functions_and_methods:
returnType: string
signatures: [strings.TrimSpace INPUT]
signatures: [strings.TrimSpace STRING]
---
{{< new-in 0.136.3 />}}
@@ -2,7 +2,7 @@
title: transform.CanHighlight
description: Reports whether the given code language is supported by the Chroma highlighter.
categories: []
keywords: []
keywords: [highlight]
params:
functions_and_methods:
aliases: []
@@ -0,0 +1,37 @@
---
title: transform.HTMLToMarkdown
description: Converts HTML to Markdown.
categories: []
keywords: []
params:
functions_and_methods:
returnType: string
signatures: [transform.HTMLToMarkdown INPUT]
---
{{< new-in "0.151.0" />}}
> [!note]
> This function is experimental and its API may change in the future.
The `transform.HTMLToMarkdown` function converts HTML to Markdown by utilizing the [`html-to-markdown`][] Go package.
## Usage
```go-html-template
{{ .Content | transform.HTMLToMarkdown | safeHTML }}
```
## Plugins
The conversion process is enabled by the following `html-to-markdown` plugins:
Plugin|Description
:--|:--
Base|Implements basic shared functionality
CommonMark|Implements Markdown according to the [Commonmark Spec][]
Table|Implements tables according to the [GitHub Flavored Markdown Spec][]
[`html-to-markdown`]: https://github.com/JohannesKaufmann/html-to-markdown?tab=readme-ov-file#readme
[Commonmark Spec]: https://spec.commonmark.org/current/
[GitHub Flavored Markdown Spec]: https://github.github.com/gfm/
@@ -2,7 +2,7 @@
title: transform.HighlightCodeBlock
description: Highlights code received in context within a code block render hook.
categories: []
keywords: []
keywords: [highlight]
params:
functions_and_methods:
aliases: []
+13 -2
View File
@@ -63,7 +63,13 @@ output
With `html` and `htmlAndMathml` you must include the KaTeX style sheet within the `head` element of your base template.
```html
<link href="https://cdn.jsdelivr.net/npm/katex@0.16.22/dist/katex.min.css" rel="stylesheet">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.16.25/dist/katex.min.css"
integrity="sha384-WcoG4HRXMzYzfCgiyfrySxx90XSl2rxY5mnVY5TwtWE6KLrArNKn0T/mOgNL0Mmi"
crossorigin="anonymous"
>
```
strict
: {{< new-in 0.147.6 />}}
@@ -132,7 +138,12 @@ Step 3
<head>
{{ $noop := .WordCount }}
{{ if .Page.Store.Get "hasMath" }}
<link href="https://cdn.jsdelivr.net/npm/katex@0.16.22/dist/katex.min.css" rel="stylesheet">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.16.25/dist/katex.min.css"
integrity="sha384-WcoG4HRXMzYzfCgiyfrySxx90XSl2rxY5mnVY5TwtWE6KLrArNKn0T/mOgNL0Mmi"
crossorigin="anonymous"
>
{{ end }}
</head>
```
+19 -20
View File
@@ -13,6 +13,25 @@ aliases: [/functions/transform.unmarshal]
The input can be a string or a [resource](g).
## Options
delimiter
: (`string`) Applicable to CSV files. The delimiter used. Default is `,`.
comment
: (`string`) Applicable to CSV files. The comment character used in the CSV. If set, lines beginning with the comment character without preceding whitespace are ignored.
format
: {{< new-in 0.149.0 />}}
: (`string`) The serialization format of the input, one of `csv`, `json`, `org`, `toml`, `xml`, or `yaml`. If empty or unspecified, Hugo infers the format from the input. For resources, this option is only needed if the file lacks an extension or to override the inferred format. For strings, it's only required when the format is ambiguous.
lazyQuotes
: (`bool`) Applicable to CSV files. Whether to allow a quote in an unquoted field, or to allow a non-doubled quote in a quoted field. Default is `false`.
targetType
: {{< new-in 0.146.7 />}}
: (`string`) Applicable to CSV files. The target data type, either `slice` or `map`. Default is `slice`.
## Unmarshal a string
```go-html-template
@@ -116,26 +135,6 @@ A remote resource is a file on a remote server, accessible via HTTP or HTTPS.
## Working with CSV
### Options
When unmarshaling a CSV file, provide an optional map of options.
delimiter
: (`string`) The delimiter used. Default is `,`.
comment
: (`string`) The comment character used in the CSV. If set, lines beginning with the comment character without preceding whitespace are ignored.
lazyQuotes
: {{< new-in 0.122.0 />}}
: (`bool`) Whether to allow a quote in an unquoted field, or to allow a non-doubled quote in a quoted field. Default is `false`.
targetType
: {{< new-in 0.146.7 />}}
: (`string`) The target data type, either `slice` or `map`. Default is `slice`.
### Examples
The examples below use this CSV file:
```csv
@@ -10,8 +10,6 @@ params:
signatures: [transform.XMLEscape INPUT]
---
{{< new-in 0.121.0 />}}
The `transform.XMLEscape` function removes [disallowed characters] as defined in the XML specification, then escapes the result by replacing the following characters with [HTML entities]:
- `"``&#34;`
+2 -2
View File
@@ -59,7 +59,7 @@ View your site at the URL displayed in your terminal. Press `Ctrl + C` to stop H
### Explanation of commands
Create the [directory structure] for your project in the `quickstart` directory.
Create the [site skeleton] for your project in the `quickstart` directory.
```text
hugo new site quickstart
@@ -199,7 +199,7 @@ For other resources to help you learn Hugo, including books and video tutorials,
[Ananke]: https://github.com/theNewDynamic/gohugo-theme-ananke
[are different applications]: https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.3
[demonstration site]: https://gohugo-ananke-theme-demo.netlify.app/
[directory structure]: /getting-started/directory-structure/
[site skeleton]: /getting-started/directory-structure/#site-skeleton
[documentation]: https://github.com/theNewDynamic/gohugo-theme-ananke#readme
[draft, future, and expired content]: /getting-started/usage/#draft-future-and-expired-content
[draft, future, or expired content]: /getting-started/usage/#draft-future-and-expired-content
+1 -1
View File
@@ -18,7 +18,7 @@ hugo version
You should see something like:
```text
hugo v0.123.0-3c8a4713908e48e6523f058ca126710397aa4ed5+extended linux/amd64 BuildDate=2024-02-19T16:32:38Z VendorInfo=gohugoio
hugo v0.152.2-6abdacad3f3fe944ea42177844469139e81feda6+extended linux/amd64 BuildDate=2025-10-24T15:31:49Z VendorInfo=gohugoio
```
## Display available commands
@@ -73,7 +73,7 @@ Now that you can log in with your SSH key, let's create a script to automate dep
## Shell script
Create a new script called `deploy` the root of your Hugo tree:
Create a new script called `deploy` at the root of your Hugo tree:
```txt
~/websites/topologix.fr$ editor deploy
@@ -40,9 +40,9 @@ Step 2
env:
variables:
# Application versions
DART_SASS_VERSION: 1.90.0
GO_VERSION: 1.24.5
HUGO_VERSION: 0.148.2
DART_SASS_VERSION: 1.96.0
GO_VERSION: 1.25.5
HUGO_VERSION: 0.152.2
# Time zone
TZ: Europe/Oslo
# Cache
@@ -25,8 +25,6 @@ Step 1
: Create a `wrangler.toml` file in the root of your project.
```toml {file="wrangler.toml" copy=true}
# Configure Cloudflare Worker
name = "hosting-cloudflare-worker"
compatibility_date = "2025-07-31"
@@ -35,7 +33,7 @@ Step 1
[assets]
directory = "./public"
not_found_handling = "404"
not_found_handling = "404-page"
```
Step 2
@@ -53,10 +51,10 @@ Step 2
main() {
DART_SASS_VERSION=1.90.0
GO_VERSION=1.24.5
HUGO_VERSION=0.148.2
NODE_VERSION=22.18.0
DART_SASS_VERSION=1.96.0
GO_VERSION=1.25.5
HUGO_VERSION=0.152.2
NODE_VERSION=24.12.0
export TZ=Europe/Oslo
@@ -1,282 +0,0 @@
---
title: Host on Codeberg Pages
description: Host your site on Codeberg Pages.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-codeberg/]
---
## Assumptions
- Working familiarity with [Git] for version control
- Completion of the Hugo [Quick Start]
- A [Codeberg account]
- A Hugo website on your local machine that you are ready to publish
[Codeberg account]: https://codeberg.org/user/login/
[Git]: https://git-scm.com/
[Quick Start]: /getting-started/quick-start/
Any and all mentions of `<YourUsername>` refer to your actual Codeberg username and must be substituted accordingly. Likewise, `<YourWebsite>` represents your actual website name.
## BaseURL
The [`baseURL`] in your site configuration must reflect the full URL provided by Codeberg Pages if using the default address (e.g. `https://<YourUsername>.codeberg.page/`). If you want to use another domain, follow the instructions in the [custom domain section] of the official documentation.
[`baseURL`]: /configuration/all/#baseurl
[custom domain section]: https://docs.codeberg.org/codeberg-pages/using-custom-domain/
For more details regarding the URL of your deployed website, refer to Codeberg Pages' [quickstart instructions].
[quickstart instructions]: https://codeberg.page/
## Manual deployment
Create a public repository on your Codeberg account titled `pages` or create a branch of the same name in an existing public repository. Finally, push the contents of Hugo's output directory (by default, `public`) to it. Here's an example:
```sh
# build the website
hugo
# access the output directory
cd public
# initialize new git repository
git init
# commit and push code to main branch
git add .
git commit -m "Initial commit"
git remote add origin https://codeberg.org/<YourUsername>/pages.git
git push -u origin main
```
## Automated deployment
You can automatically deploy your Hugo website to Codeberg using one of two methods: Woodpecker CI or Forgejo Actions.
### Woodpecker CI
To use Codeberg's Woodpecker CI, you need to have or [request] access to it, as well as add a `.woodpecker.yaml` file in the root of your project. A template and additional instructions are available in the official [examples repository].
[request]: https://codeberg.org/Codeberg-e.V./requests/issues/new?template=ISSUE_TEMPLATE%2fWoodpecker-CI.yaml
[examples repository]: https://codeberg.org/Codeberg-CI/examples/src/branch/main/Hugo/.woodpecker.yaml
In this case, you must create a public repository on Codeberg (e.g. `<YourWebsite>`) and push your local project to it. Here's an example:
```sh
# initialize new git repository
git init
# add /public directory to our .gitignore file
echo "/public" >> .gitignore
# commit and push code to main branch
git add .
git commit -m "Initial commit"
git remote add origin https://codeberg.org/<YourUsername>/<YourWebsite>.git
git push -u origin main
```
Your project will then be built and deployed by Codeberg's Woodpecker CI.
### Forgejo Actions
The other way to deploy your website to Codeberg pages automatically is to make use of Forgejo Actions. Actions need a _runner_ to work, and Codeberg has [great documentation] on how to set one up yourself. However, Codeberg provides a [handful of humble runners] themselves (they say this feature is in "open alpha"), which actually seem powerful enough to build at least relatively simple websites.
[great documentation]: https://docs.codeberg.org/ci/actions/
[handful of humble runners]: https://codeberg.org/actions/meta
To deploy your website this way, you don't need to request any access. All you need to do is enable actions in your repository settings (see the documentation link above) and add a workflow configuration file, for example, `hugo.yaml`, to the `.forgejo/workflows/` directory in your website's source repository.
Two examples of such a file are provided below.
The first file should work for automatically building your website from the source branch (`main` in this case) and committing the result to the target branch (`pages`). Without changes, this file should make your built website accessible under `https://<YourUsername>.codeberg.page/<YourWebsiteRepositoryName>/`:
```yaml {file=".forgejo/workflows/hugo.yaml" copy=true}
name: Deploy Hugo site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches:
# If you want to build from a different branch, change it here.
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
# You can find the list of available runners on https://codeberg.org/actions/meta, or run one yourself.
runs-on: codeberg-tiny-lazy
container:
# Specify "hugomods/hugo:exts" if you want to always use the latest version of Hugo for building.
image: "hugomods/hugo:exts-0.148.0"
steps:
- name: Clone the repository
uses: https://code.forgejo.org/actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Generate static files with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify
- name: Upload generated files
uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: Generated files
path: public/
deploy:
needs: [ build ]
runs-on: codeberg-tiny-lazy
steps:
- name: Clone the repository
uses: https://code.forgejo.org/actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Checkout the target branch and clean it up
# If you want to commit to a branch other than "pages", change the two references below, as well as the reference in the last step.
run: |
git checkout pages || git switch --orphan pages && \
rm -Rfv $(ls -A | egrep -v '^(\.git|LICENSE)$')
- name: Download generated files
uses: https://code.forgejo.org/actions/download-artifact@v3
with:
name: Generated files
- name: Publish the website
run: |
git config user.email codeberg-ci && \
git config user.name "Codeberg CI" && \
git add . && \
git commit --allow-empty --message "Codeberg build for ${GITHUB_SHA}" && \
git push origin pages
```
The second file implements a more complex scenario: having your website sources in one repository and the resulting static website in another repository (in this case, `pages`). If you want Codeberg to make your website available at the root of your pages subdomain (`https://<YourUsername>.codeberg.page/`), you have to push that website to the default branch of your repository named `pages`.
Since this action involves more than one repository, it will require a bit more preparation:
1. Create the target repository. Name it `pages`.
1. Generate a new SSH key. Do not use any of your own SSH keys for this, but generate one for this specific task only. On Linux, BSD, and, likely, other operating systems, you can open a terminal emulator and run the following command to generate the key:
```shell
ssh-keygen -f pagesbuild -P ""
```
This will generate two files in your current directory: `pagesbuild` (private key) and `pagesbuild.pub` (public key).
1. Add the newly generated public key as a deploy key to your `pages` repository: navigate to its Settings, click on "Deploy keys" in the left menu, click the "Add deploy key" button, give it a name (e.g. "Actions deploy key"), paste the contents of the **public** key file (`pagesbuild.pub`) to the Content field, tick the "Enable write access" checkbox, then submit the form.
1. Navigate back to your source repository settings, expand the "Actions" menu and click on "Secrets". Then click "Add Secret", enter "DEPLOY_KEY" as the secret name and paste the contents of the newly generated **private** key file (`pagesbuild`) into the Value field.
1. Navigate to the "Variables" submenu of the "Actions" menu and add the following variables:
Name|Value
:--|:--
`TARGET_REPOSITORY`|`<YourUsername>/pages`
`TARGET_BRANCH`|`main` (enter the default branch name of the `pages` repo here)
`SSH_KNOWN_HOSTS`|(paste the output you get by running `ssh-keyscan codeberg.org` in the terminal)
Once you've done all of the above, commit the following file to your repository as `.forgejo/workflows/hugo.yaml`. As you can see, the `deploy` job of this workflow is slightly different from the file above:
```yaml {file=".forgejo/workflows/hugo.yaml" copy=true}
name: Deploy Hugo site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches:
# If you want to build from a different branch, change it here.
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: codeberg-tiny-lazy
container:
# Specify "hugomods/hugo:exts" if you want to always use the latest version of Hugo for building.
image: "hugomods/hugo:exts-0.148.0"
steps:
- name: Clone the repository
uses: https://code.forgejo.org/actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Generate static files with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--source ${PWD} \
--destination ${PWD}/public/
- name: Upload generated files
uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: Generated files
path: public/
deploy:
needs: [ build ]
runs-on: codeberg-tiny-lazy
steps:
- name: Clone the repository
uses: https://code.forgejo.org/actions/checkout@v4
with:
repository: ${{ vars.TARGET_REPOSITORY }}
ref: ${{ vars.TARGET_BRANCH }}
submodules: recursive
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}
- name: Remove all files
run: |
rm -Rfv $(ls -A | egrep -v '^(\.git|LICENSE)$')
- name: Download generated files
uses: https://code.forgejo.org/actions/download-artifact@v3
with:
name: Generated files
- name: Commit and push the website
run: |
git config user.email codeberg-ci && \
git config user.name "Codeberg CI" && \
git add -v . && \
git commit -v --allow-empty --message "Codeberg build for ${GITHUB_SHA}" && \
git push -v origin ${{ vars.TARGET_BRANCH }}
```
Once you commit one of the two files to your website source repository, you should see your first automated build firing up pretty soon. You can also trigger it manually by navigating to the **Actions** section of your repository web page, choosing **hugo.yaml** on the left and clicking on **Run workflow**.
## Forgejo Actions custom domains
Codeberg Pages relies on a `.domains` file to identify allowed domains for a specific branch. It's important that this file is located in the root directory of your output repository or branch, rather than in the root directory of your source files. To achieve this, simply place your `.domains` file in the `static` directory of your project. When your site is built, it will be automatically copied to the `public` directory, which serves as the root of your output.
When looking at the example `.forgejo/workflows/hugo.yaml`, you'll notice that the `upload-artifact@v3` action is used to upload the public directory to the deployment branch.
By default, both `upload-artifact@v3` and `upload-artifact@v4` exclude all dot files from being uploaded unless you specifically tell them not to (you can find more details [here]).
By default, upload-artifact@v3 and upload-artifact@v4 exclude all dot files from being uploaded. You can find more details on [how to handle dot files and other file patterns in the documentation](https://github.com/actions/upload-artifact/issues/602). To make sure dot files are included, modify your workflow like this:
```yaml {file=".forgejo/workflows/hugo.yaml" copy=true}
- name: Upload generated files
uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: Generated files
path: public/
include-hidden-files: true # Prevents excluding .domains from uploading
```
If you're using a custom domain, it's important to update your workflow file accordingly.
## Other resources
- [Codeberg Pages](https://codeberg.page/)
- [Codeberg Pages official documentation](https://docs.codeberg.org/codeberg-pages/)
@@ -77,10 +77,10 @@ Step 4
build:
runs-on: ubuntu-latest
env:
DART_SASS_VERSION: 1.90.0
GO_VERSION: 1.24.5
HUGO_VERSION: 0.148.2
NODE_VERSION: 22.18.0
DART_SASS_VERSION: 1.96.0
GO_VERSION: 1.25.5
HUGO_VERSION: 0.152.2
NODE_VERSION: 24.12.0
TZ: Europe/Oslo
steps:
- name: Checkout
@@ -24,9 +24,9 @@ Define your [CI/CD](g) jobs by creating a `.gitlab-ci.yml` file in the root of y
```yaml {file=".gitlab-ci.yml" copy=true}
variables:
# Application versions
DART_SASS_VERSION: 1.90.0
HUGO_VERSION: 0.148.2
NODE_VERSION: 22.18.0
DART_SASS_VERSION: 1.96.0
HUGO_VERSION: 0.152.2
NODE_VERSION: 24.12.0
# Git
GIT_DEPTH: 0
GIT_STRATEGY: clone
@@ -35,7 +35,7 @@ variables:
TZ: Europe/Oslo
image:
name: golang:1.24.5-bookworm
name: golang:1.25.5-bookworm
pages:
stage: deploy
@@ -23,108 +23,99 @@ Please complete the following tasks before continuing:
## Procedure
<!-- Using "text" as the code block language because "toml" looks terrible. -->
Step 1
: Log in to your Netlify account, navigate to the Sites page, press the **Add new site** button, and choose "Import an existing project" from the dropdown menu.
: Create a `netlify.toml` file in the root of your project.
```text {file="netlify.toml" copy=true}
[build.environment]
DART_SASS_VERSION = "1.96.0"
GO_VERSION = "1.25.5"
HUGO_VERSION = "0.152.2"
NODE_VERSION = "24.12.0"
TZ = "Europe/Oslo"
[build]
publish = "public"
command = """\
git config core.quotepath false && \
hugo --gc --minify --baseURL "${URL}"
"""
```
If your site requires Dart Sass to transpile Sass to CSS, set the `DART_SASS_VERSION` and include the Dart Sass installation in the build step.
```text {file="netlify.toml" copy=true}
[build.environment]
DART_SASS_VERSION = "1.96.0"
GO_VERSION = "1.25.5"
HUGO_VERSION = "0.152.2"
NODE_VERSION = "24.12.0"
TZ = "Europe/Oslo"
[build]
publish = "public"
command = """\
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
export PATH="${HOME}/.local/dart-sass:${PATH}" && \
git config core.quotepath false && \
hugo --gc --minify --baseURL "${URL}"
"""
```
Step 2
: Select your deployment method.
![screen capture](netlify-step-02.png)
: Commit the changes to your local Git repository and push to your GitHub repository.
Step 3
: Authorize Netlify to connect with your GitHub account by pressing the **Authorize Netlify** button.
: In the upper right corner of the Netlify dashboard, press the **Add new project** button and select “Import an existing project".
![screen capture](netlify-step-03.png)
![screen capture](netlify-01.png)
Step 4
: Press the **Configure Netlify on GitHub** button.
: Connect to GitHub.
![screen capture](netlify-step-04.png)
![screen capture](netlify-02.png)
Step 5
: Install the Netlify app by selecting your GitHub account.
: Press the "Authorize Netlify" button to allow the Netlify application to access your GitHub account.
![screen capture](netlify-step-05.png)
![screen capture](netlify-03.png)
Step 6
: Press the **Install** button.
![screen capture](netlify-step-06.png)
: Press the **Configure Netlify on GitHub** button.
![screen capture](netlify-04.png)
Step 7
: Click on the site's repository from the list.
: Select the GitHub account where you want to install the Netlify application.
![screen capture](netlify-step-07.png)
![screen capture](netlify-05.png)
Step 8
: Set the site name and branch from which to deploy.
: Authorize the Netlify application to access all repositories or only select repositories, then press the Install button.
![screen capture](netlify-step-08.png)
![screen capture](netlify-06.png)
Your browser will be redirected to the Netlify dashboard.
Step 9
: Define the build settings, press the **Add environment variables** button, then press the **New variable** button.
: Click on the name of the repository you wish to import.
![screen capture](netlify-step-09.png)
![screen capture](netlify-07.png)
Step 10
: Create a new environment variable named `HUGO_VERSION` and set the value to the [latest version](https://github.com/gohugoio/hugo/releases/latest).
: On the "Review configuration" page, enter a project name, leave the settings at their default values, then press the **Deploy** button.
![screen capture](netlify-step-10.png)
![screen capture](netlify-08.png)
![screen capture](netlify-09.png)
Step 11
: Press the "Deploy my new site" button at the bottom of the page.
: When the deployment completes, click on the link to your published site.
![screen capture](netlify-step-11.png)
![screen capture](netlify-10.png)
Step 12
: At the bottom of the screen, wait for the deploy to complete, then click on the deploy log entry.
![screen capture](netlify-step-12.png)
Step 13
: Press the **Open production deploy** button to view the live site.
![screen capture](netlify-step-13.png)
## Configuration file
In the procedure above we configured our site using the Netlify user interface. Most site owners find it easier to use a configuration file checked into source control.
Create a new file named `netlify.toml` in the root of your project directory. In its simplest form, the configuration file might look like this:
```toml {file="netlify.toml"}
[build.environment]
GO_VERSION = "1.24.5"
HUGO_VERSION = "0.148.2"
NODE_VERSION = "22.18.0"
TZ = "Europe/Oslo"
[build]
publish = "public"
command = """\
git config core.quotepath false && \
hugo --gc --minify --baseURL "${URL}"
"""
```
If your site requires Dart Sass to transpile Sass to CSS, the configuration file should look something like this:
```toml {file="netlify.toml"}
[build.environment]
DART_SASS_VERSION = "1.90.0"
GO_VERSION = "1.24.5"
HUGO_VERSION = "0.148.2"
NODE_VERSION = "22.18.0"
TZ = "Europe/Oslo"
[build]
publish = "public"
command = """\
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
export PATH="${HOME}/.local/dart-sass:${PATH}" && \
git config core.quotepath false && \
hugo --gc --minify --baseURL "${URL}"
"""
```
In the future, whenever you push a change from your local Git repository, Netlify will rebuild and deploy your site.
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

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