Compare commits

...

31 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen 767d3c0e73 server: Strip ANSI escape codes from browser error log
Fixes #13037
2024-11-14 10:13:52 +01:00
Bjørn Erik Pedersen 8aba6dc661 parser/metadecoders: Add benchmark 2024-11-13 14:57:18 +01:00
Bjørn Erik Pedersen a7df536a52 Add site.Store and hugo.Store and Shortcode.Store
Closes #13021
2024-11-13 12:41:16 +01:00
Bjørn Erik Pedersen 3477d9fcec Merge commit 'de0df119b504a91c9e1f442b07954f366ffb2932' 2024-11-13 11:07:57 +01:00
Bjørn Erik Pedersen de0df119b5 Squashed 'docs/' changes from ccb1b97cb..159c843fd
159c843fd Fix front matter menu entry example
c3a476a19 Document soft deprecation of PAGE.Scratch
cdead9785 netlify: Hugo 0.138.0
9169b4da4 Update version references
3bc6bf431 Update embedded.md
5c7743b2e Update creation instructions for the emoji quick reference
109efe3eb Document the comment shortcode
83d7d3005 Update theme
d3c205054 netlify: Hugo 0.137.1
545290351 Handle inline HTML content
0204be97d Update theme
18d09235e Remove JS and CSS that prevents FOUC with client side math rendering
63d9dd876 Update RenderShortcodes.md
064b95539 Update output-format-definition.md
3744f3be2 Describe and refer to the extended/deploy edition
3d3302308 netlify: Hugo 0.137.0
b53aedcea Update RenderShortcodes.md
b5f289165 Replace HTML comments in markdown with the new comment shortcode
c673880b6 Remove superfluous right bracket
f80b0c61e Update faq.md
2ede707eb Document installation on NixOS
09b114914 Update theme
76a9f90b2 Update passthrough.md
9f3355630 Update Scratch.md
bc080ecaa Update Store.md
1507ede32 Update Scratch.md
54a90f569 Update Store.md
7c9145c43 Fix broken link
dd15f183b Update ToMath.md
2b021c34b Move the [build] documentation to its own page
cbb6677ec Fix typo
ac0969063 Update ToMath.md
7fbdfd7c8 netlify: Hugo 0.136.5
17f54223c Update ToMath.md
4c9c3bb06 Update multilingual.md
1432da7bd Make site and page language methods linkable
fd5b746cb Update urls.md
a746f1b3a Update urls.md
abf8738e2 netlify: Hugo 0.136.4
bd8759996 Update TrimSpace.md
6103c1e84 Documents strings.TrimSpace
533dd3a7b netlify: Hugo 0.136.3
30f3f97cf Update quick-start.md
b0d7b41a0 Update configuration-markup.md
760e5e4f0 Update quick-start.md
17daeb866 Update quick-start.md
1e158e723 netlify: Hugo 0.136.2
d32530839 Update theme
edb9bee02 Update description of url front matter field
e1c576e18 netlify: Hugo 0.136.1
1ad28e1e0 Describe how to configure uglyURLs per section
cbbd4c4fe netlify: Hugo 0.136.0
bb7f35e99 Merge branch 'tempv0.136.0'
706110736 docs: Regen CLI docs
bf0c7821f Update urls.md
8c544e6c0 Update quick-start.md
8d02733d0 Update Paginator.md
a45327aac Update Paginate.md
1377ed4de Clarify date parsing
e19fb8043 Document front matter date field aliases
a39951847 Update Tailwind CSS installation instructions
3be164c35 Remove duplicate token
05fc815f7 commands: Add "hugo build" as an alias for "hugo"
cb3cb504c Update table render hook example
efbee0bff Clarify resources.GetRemote 404 handling
4312d49c9 Update compare.Conditional documentation
4a46d53b6 Update theme
93e542d4f netlify: Hugo 0.135.0
b4da1c104 Remvoe some old new-in shortcodes
4c316f051 Update TailwindCSS.md
c2fe91509 Update introduction.md
906b7c66b Update configuration.md
5ab6b3cdd Update documentation.md
26fb4bb4c Update documentation.md
e9e917f37 Update version refs
83ce07f24 netlify: Hugo 0.134.3
8cb32f802 Update front-matter.md
94d7f576a Update faq.md
fafc1d8d9 netlify: Hugo 0.134.2
bfe9cdc3d Update content-adapters.md
9e49ae3e1 Document ignoreLogs configuration setting
6b47a1d57 Update configuration.md
fd98a0372 Document CLI options that can be set in configuration
07c2400d8 Document alternative to Summary method
d053fa163 Update to reflect changes in v0.134.1
137dc3241 Update ContentWithoutSummary.md
e8f6427d9 netlify: Hugo 0.134.1

git-subtree-dir: docs
git-subtree-split: 159c843fd7
2024-11-13 11:07:57 +01:00
Andreas Deininger e79ee0d516 markup/goldmark: Fix typo in error message 2024-11-13 10:12:26 +01:00
Joe Mooring 2b97a2a8bf markup/goldmark: Improve the raw HTML omitted warning
Closes #13023
2024-11-07 23:00:09 +02:00
hugoreleaser 35afe6fe2a releaser: Prepare repository for 0.139.0-DEV
[ci skip]
2024-11-06 11:36:12 +00:00
hugoreleaser ad82998d54 releaser: Bump versions for release of 0.138.0
[ci skip]
2024-11-06 11:22:34 +00:00
Bjørn Erik Pedersen 95e2d5beb8 Fix concurrent map read and map write in short page lookups
Regression introduced in Hugo `v0.137.0`.

Fixes #13019
2024-11-06 12:17:30 +01:00
Bjørn Erik Pedersen 2c3efc8106 Alias Page.Scratch to Page.Store (note)
Fixes #13016
2024-11-06 09:49:23 +01:00
hugoreleaser df8bd4af4f releaser: Prepare repository for 0.138.0-DEV
[ci skip]
2024-11-05 12:04:27 +00:00
hugoreleaser 17e15b2148 releaser: Bump versions for release of 0.137.1
[ci skip]
2024-11-05 11:49:09 +00:00
Bjørn Erik Pedersen ca4fc587c3 common/hugo: Add withdeploy to the version string printed in hugo version 2024-11-05 11:40:42 +01:00
Bjørn Erik Pedersen 4faaaf9c2f markup: Goldmark log "Raw HTML omitted" warning also for inline HTML
Fixes #13013
2024-11-05 11:40:42 +01:00
Bjørn Erik Pedersen 94b46c36b4 build: Add missing withdeploy archive for Windows
Fixes #13009
2024-11-05 11:40:42 +01:00
Bjørn Erik Pedersen 2b0b3b8584 commands: Print the "deploy not available" error message even if flags provided
Fixes #13012
2024-11-05 11:40:42 +01:00
Joe Mooring 801035bb7a tpl/tplimpl: Create an embedded comment shortcode
Closes #13010
2024-11-04 21:05:07 +01:00
hugoreleaser b7861e586e releaser: Prepare repository for 0.138.0-DEV
[ci skip]
2024-11-04 16:19:39 +00:00
hugoreleaser 59c1158135 releaser: Bump versions for release of 0.137.0
[ci skip]
2024-11-04 16:04:06 +00:00
Bjørn Erik Pedersen fcdc454cc5 Do not watch directories with no mounted files in it
Fixes #12912
Fixes #13007
2024-11-04 12:44:07 +01:00
Bjørn Erik Pedersen 6cf23bf882 markup/goldmark: Only log Raw HTML omitted WARN on block entering
Updates #12997
2024-11-04 10:13:53 +01:00
Bjørn Erik Pedersen 62a96cef7f markup/goldmark: Add warning (using Warnidf) on Goldmark <!-- raw HTML omitted -->
Fixes #12997
2024-11-03 14:17:10 +01:00
Bjørn Erik Pedersen 30d9aea860 Fix stale pages on rebuilds in GetPage with short refs
Fixes #13004
2024-11-03 13:33:31 +01:00
Bjørn Erik Pedersen 1f23b4949c Fix some RenderShortcodes error cases
This issue fixes two cases where `{{__hugo_ctx` artifacts were left in the rendered output:

1. Inclusion when `.RenderShortcodes` is wrapped in HTML.
2. Inclusion of Markdown file without a trailing newline in some cases.

Closes #12854
Updates #12998
2024-11-03 13:33:31 +01:00
Joe Mooring 5fc1639035 Update README.md 2024-11-01 21:10:52 -07:00
Joe Mooring 889308dd85 resources: Address Dart Sass deprecation of global built-in functions
See https://github.com/sass/dart-sass/releases/tag/1.80.0

Fixes #12961
2024-11-01 14:05:27 +01:00
Joe Mooring 72352f205a github: Adjust test workflow to install Dart Sass v1.80.3 2024-11-01 13:37:45 +01:00
Bjørn Erik Pedersen e3304db617 deps: Upgrade github.com/bep/godartsass/v2 v2.1.0 => v2.2.0 2024-11-01 12:37:55 +01:00
Bjørn Erik Pedersen 1ec6fa36c0 Update README.md 2024-11-01 10:16:05 +01:00
Bjørn Erik Pedersen 89bd025ebf Build without the deploy feature by default
Build tags setup changed to:

* !nodeploy => withdeploy
* nodeploy => !withdeploy

Also move the deploy feature out into its own release archives.

See #12994 for the primary motivation for this change. But this also greatly reduces the number of dependencies in Hugo when you don't need this feature and cuts the binary size greatly.

Fixes #12994
2024-10-30 11:46:40 +01:00
155 changed files with 1893 additions and 1183 deletions
+7 -7
View File
@@ -6,10 +6,10 @@ name: Test
env:
GOPROXY: https://proxy.golang.org
GO111MODULE: on
SASS_VERSION: 1.63.2
DART_SASS_SHA_LINUX: 3ea33c95ad5c35fda6e9a0956199eef38a398f496cfb8750e02479d7d1dd42af
DART_SASS_SHA_MACOS: 11c70f259836b250b44a9cb57fed70e030f21f45069b467d371685855f1eb4f0
DART_SASS_SHA_WINDOWS: cd8cd36a619dd8e27f93d3186c52d70eb7d69472aa6c85f5094b29693e773f64
SASS_VERSION: 1.80.3
DART_SASS_SHA_LINUX: 7c933edbad0a7d389192c5b79393485c088bd2c4398e32f5754c32af006a9ffd
DART_SASS_SHA_MACOS: 79e060b0e131c3bb3c16926bafc371dc33feab122bfa8c01aa337a072097967b
DART_SASS_SHA_WINDOWS: 0bc4708b37cd1bac4740e83ac5e3176e66b774f77fd5dd364da5b5cfc9bfb469
permissions:
contents: read
jobs:
@@ -112,17 +112,17 @@ jobs:
sass --version;
mage -v check;
env:
HUGO_BUILD_TAGS: extended
HUGO_BUILD_TAGS: extended,withdeploy
- if: matrix.os == 'windows-latest'
# See issue #11052. We limit the build to regular test (no -race flag) on Windows for now.
name: Test
run: |
mage -v test;
env:
HUGO_BUILD_TAGS: extended
HUGO_BUILD_TAGS: extended,withdeploy
- name: Build tags
run: |
go install -tags extended,nodeploy
go install -tags extended
- if: matrix.os == 'ubuntu-latest'
name: Build for dragonfly
run: |
+3 -1
View File
@@ -1,3 +1,5 @@
*.test
imports.*
imports.*
dist/
public/
+2 -2
View File
@@ -21,8 +21,8 @@ COPY --from=xx / /
ARG TARGETPLATFORM
RUN xx-apk add musl-dev gcc g++
# Optionally set HUGO_BUILD_TAGS to "none" or "nodeploy" when building like so:
# docker build --build-arg HUGO_BUILD_TAGS=nodeploy .
# Optionally set HUGO_BUILD_TAGS to "none" or "withdeploy" when building like so:
# docker build --build-arg HUGO_BUILD_TAGS=withdeploy .
#
# We build the extended version by default.
ARG HUGO_BUILD_TAGS="extended"
+3 -2
View File
@@ -33,8 +33,7 @@ A fast and flexible static site generator built with love by [bep], [spf13], and
[![Tests on Linux, MacOS and Windows](https://github.com/gohugoio/hugo/workflows/Test/badge.svg)](https://github.com/gohugoio/hugo/actions?query=workflow%3ATest)
[![Go Report Card](https://goreportcard.com/badge/github.com/gohugoio/hugo)](https://goreportcard.com/report/github.com/gohugoio/hugo)
[Website] | [Installation] | [Documentation] | [Support] | [Contributing] | <a rel="me" href="https://fosstodon.org/@gohugoio">Mastodon</a> | <a rel="me" href="https://x.com/gohugoiov2">X</a>
[Website] | [Installation] | [Documentation] | [Support] | [Contributing] | <a rel="me" href="https://fosstodon.org/@gohugoio">Mastodon</a>
## Overview
Hugo is a [static site generator] written in [Go], optimized for speed and designed for flexibility. With its advanced templating system and fast asset pipelines, Hugo renders a complete site in seconds, often less.
@@ -68,6 +67,8 @@ See the [features] section of the documentation for a comprehensive summary of H
<a href="https://www.linode.com/?utm_campaign=hugosponsor&utm_medium=banner&utm_source=hugogithub" target="_blank"><img src="https://raw.githubusercontent.com/gohugoio/gohugoioTheme/master/assets/images/sponsors/linode-logo_standard_light_medium.png" width="200" alt="Linode"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://route4me.com/" target="_blank"><img src="https://raw.githubusercontent.com/gohugoio/gohugoioTheme/master/assets/images/sponsors/Route4MeLogoBlueOnWhite.svg" width="200" alt="Route Planning & Route Optimization Software"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://www.jetbrains.com/go/?utm_source=OSS&utm_medium=referral&utm_campaign=hugo" target="_blank"><img src="https://raw.githubusercontent.com/gohugoio/gohugoioTheme/master/assets/images/sponsors/goland.svg" width="200" alt="The complete IDE crafted for professional Go developers."></a>
</p>
## Installation
+3 -27
View File
@@ -11,21 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodeploy
// +build !nodeploy
// Copyright 2024 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build withdeploy
// +build withdeploy
package commands
@@ -33,7 +20,6 @@ import (
"context"
"github.com/gohugoio/hugo/deploy"
"github.com/gohugoio/hugo/deploy/deployconfig"
"github.com/bep/simplecobra"
"github.com/spf13/cobra"
@@ -60,17 +46,7 @@ documentation.
return deployer.Deploy(ctx)
},
withc: func(cmd *cobra.Command, r *rootCommand) {
cmd.ValidArgsFunction = cobra.NoFileCompletions
cmd.Flags().String("target", "", "target deployment from deployments section in config file; defaults to the first one")
_ = cmd.RegisterFlagCompletionFunc("target", cobra.NoFileCompletions)
cmd.Flags().Bool("confirm", false, "ask for confirmation before making changes to the target")
cmd.Flags().Bool("dryRun", false, "dry run")
cmd.Flags().Bool("force", false, "force upload of all files")
cmd.Flags().Bool("invalidateCDN", deployconfig.DefaultConfig.InvalidateCDN, "invalidate the CDN cache listed in the deployment target")
cmd.Flags().Int("maxDeletes", deployconfig.DefaultConfig.MaxDeletes, "maximum # of files to delete, or -1 to disable")
_ = cmd.RegisterFlagCompletionFunc("maxDeletes", cobra.NoFileCompletions)
cmd.Flags().Int("workers", deployconfig.DefaultConfig.Workers, "number of workers to transfer files. defaults to 10")
_ = cmd.RegisterFlagCompletionFunc("workers", cobra.NoFileCompletions)
applyDeployFlags(cmd, r)
},
}
}
+33
View File
@@ -0,0 +1,33 @@
// Copyright 2024 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"github.com/gohugoio/hugo/deploy/deployconfig"
"github.com/spf13/cobra"
)
func applyDeployFlags(cmd *cobra.Command, r *rootCommand) {
cmd.ValidArgsFunction = cobra.NoFileCompletions
cmd.Flags().String("target", "", "target deployment from deployments section in config file; defaults to the first one")
_ = cmd.RegisterFlagCompletionFunc("target", cobra.NoFileCompletions)
cmd.Flags().Bool("confirm", false, "ask for confirmation before making changes to the target")
cmd.Flags().Bool("dryRun", false, "dry run")
cmd.Flags().Bool("force", false, "force upload of all files")
cmd.Flags().Bool("invalidateCDN", deployconfig.DefaultConfig.InvalidateCDN, "invalidate the CDN cache listed in the deployment target")
cmd.Flags().Int("maxDeletes", deployconfig.DefaultConfig.MaxDeletes, "maximum # of files to delete, or -1 to disable")
_ = cmd.RegisterFlagCompletionFunc("maxDeletes", cobra.NoFileCompletions)
cmd.Flags().Int("workers", deployconfig.DefaultConfig.Workers, "number of workers to transfer files. defaults to 10")
_ = cmd.RegisterFlagCompletionFunc("workers", cobra.NoFileCompletions)
}
+5 -3
View File
@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build nodeploy
// +build nodeploy
//go:build !withdeploy
// +build !withdeploy
// Copyright 2024 The Hugo Authors. All rights reserved.
//
@@ -31,6 +31,7 @@ package commands
import (
"context"
"errors"
"github.com/bep/simplecobra"
"github.com/spf13/cobra"
@@ -40,9 +41,10 @@ func newDeployCommand() simplecobra.Commander {
return &simpleCommand{
name: "deploy",
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
return nil
return errors.New("deploy not supported in this version of Hugo; install a release with 'withdeploy' in the archive filename or build yourself with the 'withdeploy' build tag. Also see https://github.com/gohugoio/hugo/pull/12995")
},
withc: func(cmd *cobra.Command, r *rootCommand) {
applyDeployFlags(cmd, r)
cmd.Hidden = true
},
}
+2
View File
@@ -21,6 +21,8 @@ const (
ErrRemoteGetCSV = "error-remote-getcsv"
WarnFrontMatterParamsOverrides = "warning-frontmatter-params-overrides"
WarnRenderShortcodesInHTML = "warning-rendershortcodes-in-html"
WarnGoldmarkRawHTML = "warning-goldmark-raw-html"
)
// Field/method names with special meaning.
+10
View File
@@ -33,6 +33,7 @@ import (
"github.com/gohugoio/hugo/common/hcontext"
"github.com/gohugoio/hugo/common/hexec"
"github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/hugofs/files"
"github.com/spf13/afero"
@@ -55,6 +56,8 @@ var (
vendorInfo string
)
var _ maps.StoreProvider = (*HugoInfo)(nil)
// HugoInfo contains information about the current Hugo environment
type HugoInfo struct {
CommitHash string
@@ -72,6 +75,8 @@ type HugoInfo struct {
conf ConfigProvider
deps []*Dependency
store *maps.Scratch
// Context gives access to some of the context scoped variables.
Context Context
}
@@ -116,6 +121,10 @@ func (i HugoInfo) Deps() []*Dependency {
return i.deps
}
func (i HugoInfo) Store() *maps.Scratch {
return i.store
}
// Deprecated: Use hugo.IsMultihost instead.
func (i HugoInfo) IsMultiHost() bool {
Deprecate("hugo.IsMultiHost", "Use hugo.IsMultihost instead.", "v0.124.0")
@@ -185,6 +194,7 @@ func NewInfo(conf ConfigProvider, deps []*Dependency) HugoInfo {
Environment: conf.Environment(),
conf: conf,
deps: deps,
store: maps.NewScratch(),
GoVersion: goVersion,
}
}
+19
View File
@@ -0,0 +1,19 @@
// Copyright 2024 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build withdeploy
// +build withdeploy
package hugo
var IsWithdeploy = true
+19
View File
@@ -0,0 +1,19 @@
// Copyright 2024 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !withdeploy
// +build !withdeploy
package hugo
var IsWithdeploy = false
+3
View File
@@ -152,6 +152,9 @@ func BuildVersionString() string {
if IsExtended {
version += "+extended"
}
if IsWithdeploy {
version += "+withdeploy"
}
osArch := bi.GoOS + "/" + bi.GoArch
+1 -1
View File
@@ -17,7 +17,7 @@ package hugo
// This should be the only one.
var CurrentVersion = Version{
Major: 0,
Minor: 137,
Minor: 139,
PatchLevel: 0,
Suffix: "-DEV",
}
+17 -7
View File
@@ -18,18 +18,19 @@ package loggers
import (
"fmt"
"io"
"regexp"
"strings"
"sync"
"github.com/bep/logg"
)
// newNoColoursHandler creates a new NoColoursHandler
func newNoColoursHandler(outWriter, errWriter io.Writer, noLevelPrefix bool, predicate func(*logg.Entry) bool) *noColoursHandler {
// newNoAnsiEscapeHandler creates a new noAnsiEscapeHandler
func newNoAnsiEscapeHandler(outWriter, errWriter io.Writer, noLevelPrefix bool, predicate func(*logg.Entry) bool) *noAnsiEscapeHandler {
if predicate == nil {
predicate = func(e *logg.Entry) bool { return true }
}
return &noColoursHandler{
return &noAnsiEscapeHandler{
noLevelPrefix: noLevelPrefix,
outWriter: outWriter,
errWriter: errWriter,
@@ -37,7 +38,7 @@ func newNoColoursHandler(outWriter, errWriter io.Writer, noLevelPrefix bool, pre
}
}
type noColoursHandler struct {
type noAnsiEscapeHandler struct {
mu sync.Mutex
outWriter io.Writer // Defaults to os.Stdout.
errWriter io.Writer // Defaults to os.Stderr.
@@ -45,7 +46,7 @@ type noColoursHandler struct {
noLevelPrefix bool
}
func (h *noColoursHandler) HandleLog(e *logg.Entry) error {
func (h *noAnsiEscapeHandler) HandleLog(e *logg.Entry) error {
if !h.predicate(e) {
return nil
}
@@ -71,10 +72,12 @@ func (h *noColoursHandler) HandleLog(e *logg.Entry) error {
prefix = prefix + ": "
}
msg := stripANSI(e.Message)
if h.noLevelPrefix {
fmt.Fprintf(w, "%s%s", prefix, e.Message)
fmt.Fprintf(w, "%s%s", prefix, msg)
} else {
fmt.Fprintf(w, "%s %s%s", levelString[e.Level], prefix, e.Message)
fmt.Fprintf(w, "%s %s%s", levelString[e.Level], prefix, msg)
}
for _, field := range e.Fields {
@@ -88,3 +91,10 @@ func (h *noColoursHandler) HandleLog(e *logg.Entry) error {
return nil
}
var ansiRe = regexp.MustCompile(`\x1b\[[0-9;]*m`)
// stripANSI removes ANSI escape codes from s.
func stripANSI(s string) string {
return ansiRe.ReplaceAllString(s, "")
}
+40
View File
@@ -0,0 +1,40 @@
// Copyright 2024 The Hugo Authors. All rights reserved.
// Some functions in this file (see comments) is based on the Go source code,
// copyright The Go Authors and governed by a BSD-style license.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package loggers
import (
"bytes"
"testing"
"github.com/bep/logg"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/common/terminal"
)
func TestNoAnsiEscapeHandler(t *testing.T) {
c := qt.New(t)
test := func(s string) {
c.Assert(stripANSI(terminal.Notice(s)), qt.Equals, s)
}
test(`error in "file.md:1:2"`)
var buf bytes.Buffer
h := newNoAnsiEscapeHandler(&buf, &buf, false, nil)
h.HandleLog(&logg.Entry{Message: terminal.Notice(`error in "file.md:1:2"`), Level: logg.LevelInfo})
c.Assert(buf.String(), qt.Equals, "INFO error in \"file.md:1:2\"\n")
}
+2 -2
View File
@@ -62,7 +62,7 @@ func New(opts Options) Logger {
if terminal.PrintANSIColors(os.Stdout) {
logHandler = newDefaultHandler(opts.Stdout, opts.Stderr)
} else {
logHandler = newNoColoursHandler(opts.Stdout, opts.Stderr, false, nil)
logHandler = newNoAnsiEscapeHandler(opts.Stdout, opts.Stderr, false, nil)
}
errorsw := &strings.Builder{}
@@ -95,7 +95,7 @@ func New(opts Options) Logger {
}
if opts.StoreErrors {
h := newNoColoursHandler(io.Discard, errorsw, true, func(e *logg.Entry) bool {
h := newNoAnsiEscapeHandler(io.Discard, errorsw, true, func(e *logg.Entry) bool {
return e.Level >= logg.LevelError
})
+50 -4
View File
@@ -13,11 +13,14 @@
package maps
import "sync"
import (
"sync"
)
// Cache is a simple thread safe cache backed by a map.
type Cache[K comparable, T any] struct {
m map[K]T
m map[K]T
hasBeenInitialized bool
sync.RWMutex
}
@@ -34,11 +37,16 @@ func (c *Cache[K, T]) Get(key K) (T, bool) {
return zero, false
}
c.RLock()
v, found := c.m[key]
v, found := c.get(key)
c.RUnlock()
return v, found
}
func (c *Cache[K, T]) get(key K) (T, bool) {
v, found := c.m[key]
return v, found
}
// GetOrCreate gets the value for the given key if it exists, or creates it if not.
func (c *Cache[K, T]) GetOrCreate(key K, create func() (T, error)) (T, error) {
c.RLock()
@@ -61,13 +69,49 @@ func (c *Cache[K, T]) GetOrCreate(key K, create func() (T, error)) (T, error) {
return v, nil
}
// InitAndGet initializes the cache if not already done and returns the value for the given key.
// The init state will be reset on Reset or Drain.
func (c *Cache[K, T]) InitAndGet(key K, init func(get func(key K) (T, bool), set func(key K, value T)) error) (T, error) {
var v T
c.RLock()
if !c.hasBeenInitialized {
c.RUnlock()
if err := func() error {
c.Lock()
defer c.Unlock()
// Double check in case another goroutine has initialized it in the meantime.
if !c.hasBeenInitialized {
err := init(c.get, c.set)
if err != nil {
return err
}
c.hasBeenInitialized = true
}
return nil
}(); err != nil {
return v, err
}
// Reacquire the read lock.
c.RLock()
}
v = c.m[key]
c.RUnlock()
return v, nil
}
// Set sets the given key to the given value.
func (c *Cache[K, T]) Set(key K, value T) {
c.Lock()
c.m[key] = value
c.set(key, value)
c.Unlock()
}
func (c *Cache[K, T]) set(key K, value T) {
c.m[key] = value
}
// ForEeach calls the given function for each key/value pair in the cache.
func (c *Cache[K, T]) ForEeach(f func(K, T)) {
c.RLock()
@@ -81,6 +125,7 @@ func (c *Cache[K, T]) Drain() map[K]T {
c.Lock()
m := c.m
c.m = make(map[K]T)
c.hasBeenInitialized = false
c.Unlock()
return m
}
@@ -94,6 +139,7 @@ func (c *Cache[K, T]) Len() int {
func (c *Cache[K, T]) Reset() {
c.Lock()
c.m = make(map[K]T)
c.hasBeenInitialized = false
c.Unlock()
}
+7 -20
View File
@@ -22,31 +22,18 @@ import (
"github.com/gohugoio/hugo/common/math"
)
// Scratch is a writable context used for stateful operations in Page/Node rendering.
type StoreProvider interface {
// Store returns a Scratch that can be used to store temporary state.
// Store is not reset on server rebuilds.
Store() *Scratch
}
// Scratch is a writable context used for stateful build operations
type Scratch struct {
values map[string]any
mu sync.RWMutex
}
// Scratcher provides a scratching service.
type Scratcher interface {
// Scratch returns a "scratch pad" that can be used to store state.
Scratch() *Scratch
}
type scratcher struct {
s *Scratch
}
func (s scratcher) Scratch() *Scratch {
return s.s
}
// NewScratcher creates a new Scratcher.
func NewScratcher() Scratcher {
return scratcher{s: NewScratch()}
}
// Add will, for single values, add (using the + operator) the addend to the existing addend (if found).
// Supports numeric values and strings.
//
+2 -2
View File
@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodeploy
// +build !nodeploy
//go:build withdeploy
// +build withdeploy
package deploy
+2 -2
View File
@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodeploy
// +build !nodeploy
//go:build withdeploy
// +build withdeploy
package deploy
+2 -2
View File
@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !solaris && !nodeploy
// +build !solaris,!nodeploy
//go:build !solaris && withdeploy
// +build !solaris,withdeploy
package deploy
+2 -2
View File
@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodeploy
// +build !nodeploy
//go:build withdeploy
// +build withdeploy
package deploy
+2 -2
View File
@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodeploy
// +build !nodeploy
//go:build withdeploy
// +build withdeploy
package deployconfig
+2 -2
View File
@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodeploy
// +build !nodeploy
//go:build withdeploy
// +build withdeploy
package deploy
+4
View File
@@ -85,6 +85,7 @@
"stringifier",
"struct",
"toclevels",
"unpublishdate",
"zgotmplz",
"# ----------------------------------------------------------------------",
"# cspell: ignore foreign language words",
@@ -129,6 +130,7 @@
"Samsa",
"Stucki",
"Thénardier",
"WASI",
"# ----------------------------------------------------------------------",
"# cspell: ignore operating systems and software packages",
"# ----------------------------------------------------------------------",
@@ -158,10 +160,12 @@
"achristie",
"ddmaurier",
"dring",
"fleqn",
"inor",
"jausten",
"jdoe",
"jsmith",
"leqno",
"milli",
"rgba",
"rsmith",
+1 -3
View File
@@ -7,12 +7,10 @@ A fast and flexible static site generator built with love by [bep], [spf13], and
[![Netlify Status](https://api.netlify.com/api/v1/badges/e0dbbfc7-34f1-4393-a679-c16e80162705/deploy-status)](https://app.netlify.com/sites/gohugoio/deploys)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://gohugo.io/contribute/documentation/)
This is the repository for the [Hugo](https://github.com/gohugoio/hugo) documentation site.
This is the repository for the [Hugo](https://github.com/gohugoio/hugo) documentation site.
Please see the [contributing] section for guidelines, examples, and process.
[bep]: https://github.com/bep
[spf13]: https://github.com/spf13
[friends]: https://github.com/gohugoio/hugo/graphs/contributors
@@ -4,13 +4,7 @@ code, .code, pre code, .highlight pre {
}
.sans-serif {
font-family: 'Muli',
avenir,
'helvetica neue', helvetica,
ubuntu,
roboto, noto,
'segoe ui', arial,
sans-serif;
font-family: 'Muli', Avenir, 'Helvetica Neue', Helvetica, Roboto, Noto, 'Segoe UI', Arial, sans-serif;
}
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.1 KiB

@@ -5002,13 +5002,7 @@ code, .code, pre code, .highlight pre {
font-family: 'inconsolata',Menlo,Monaco,'Courier New',monospace;
}
.sans-serif {
font-family: 'Muli',
avenir,
'helvetica neue', helvetica,
ubuntu,
roboto, noto,
'segoe ui', arial,
sans-serif;
font-family: 'Muli', Avenir, 'Helvetica Neue', Helvetica, Roboto, Noto, 'Segoe UI', Arial, sans-serif;
}
.serif {
font-family: Palatino,"Palatino Linotype","Palatino LT STD","Book Antiqua",Georgia,serif;
@@ -15,9 +15,9 @@
link_attr = "style='color: #ffffff; font-weight: bold; text-decoration: none; text-align: center'"
[[banners]]
name = "Your Company?"
link = "https://bep.is/en/hugo-sponsor-2023-01/"
utm_campaign = "hugosponsor"
show_on_hover = true
bgcolor = "#4e4f4f"
link_attr = "style='color: #ffffff; font-weight: bold; text-decoration: none; text-align: center'"
name = "GoLand"
title = "The complete IDE crafted for professional Go developers."
no_query_params = true
link = "https://www.jetbrains.com/go/?utm_source=OSS&utm_medium=referral&utm_campaign=hugo"
logo = "images/sponsors/goland.svg"
bgcolor = "#f4f4f4"
@@ -106,9 +106,7 @@
</head>
<body
class="ma0 sans-serif bg-primary-color-light{{ with getenv "HUGO_ENV" }}
{{ . }}
{{ end }} {{ if $hasMath }}{{ print " dn" }}{{ end }}">
class="ma0 sans-serif bg-primary-color-light{{ with getenv "HUGO_ENV" }} {{ . }}{{ end }}">
{{ partial "hooks/after-body-start.html" . }}
{{ block "nav" . }}{{ partial "site-nav.html" . }}{{ end }}
{{ block "header" . }}{{ end }}
@@ -25,7 +25,7 @@
{{ $query_params := .query_params | default "" }}
{{ $url := .link }}
{{ if not .no_query_params }}
{{ $url = printf "%s?%s%s" .link $query_params (querify "utm_source" (.utm_source | default $utmSource ) "utm_medium" "banner" "utm_campaign" (.utm_campaign | default "hugosponsor") "utm_content" (.utm_content | default "gohugoio")) | safeURL }}
{{ $url = printf "%s?%s%s" .link $query_params (querify "utm_source" (.utm_source | default $utmSource ) "utm_medium" (.utm_medium | default "banner") "utm_campaign" (.utm_campaign | default "hugosponsor") "utm_content" (.utm_content | default "gohugoio")) | safeURL }}
{{ end }}
{{ $logo := resources.Get .logo }}
{{ $gtagID := printf "Sponsor %s %s" .name $gtag | title }}
@@ -2,15 +2,8 @@
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']], // inline
displayMath: [['$$', '$$'], ['\\[', '\\]']] // block
},
startup: {
pageReady: () => {
return MathJax.startup.defaultPageReady().then(() => {
document.body.classList.remove("dn");
});
}
displayMath: [['\\[', '\\]'], ['$$', '$$']], // block
inlineMath: [['\\(', '\\)']] // inline
}
};
</script>
@@ -1,9 +1,3 @@
<a
href="https://twitter.com/intent/follow?screen_name=gohugoiov2"
title="Follow on Twitter"
class="link-transition twitter link dib z-999 pt3 pt0-l mr2">
{{ partial "svg/twitter.svg" (dict "size" "32px") }}
</a>
<a
rel="me"
class="mstdn mr3"
@@ -4,7 +4,7 @@ If you have an "older" site running on Netlify, you may have to set GO_VERSION t
For more information about Go Modules, see:
* https://github.com/golang/go/wiki/Modules
* https://go.dev/wiki/Modules
* https://blog.golang.org/using-go-modules
` }}
@@ -1 +1 @@
Also see [Module Mounts Config](/hugo-modules/configuration/#module-configuration-mounts) for an alternative way to configure this directory (from Hugo 0.56).
Also see [Module Mounts Config](/hugo-modules/configuration/#module-configuration-mounts) for an alternative way to configure this directory.
+1 -1
View File
@@ -1 +1 @@
# github.com/gohugoio/gohugoioTheme v0.0.0-20240815082608-66ccd383a90f
# github.com/gohugoio/gohugoioTheme v0.0.0-20241105120803-6c6e5fb8f8af
@@ -91,6 +91,10 @@ Returns the `Site` to which the pages will be added.
{{ .Site.Title }}
{{< /code >}}
{{% note %}}
Note that the `Site` returned isn't fully built when invoked from the content adapters; if you try to call methods that depends on pages, e.g. `.Site.Pages`, you will get an error saying "this method cannot be called before the site is fully initialized".
{{% /note %}}
###### Store
Returns a persistent “scratch pad” to store and manipulate data. The main use case for this is to transfer values between executions when [EnableAllLanguages](#enablealllanguages) is set. See [examples](/methods/page/store/).
@@ -59,7 +59,7 @@ Create your content in [HTML] preceded by front matter. The content is typically
### Emacs Org Mode
Create your content in the [Emacs Org Mode] format preceded by front matter. You can use Org Mode keywords for front matter. See [details](/content-management/front-matter/#emacs-org-mode)).
Create your content in the [Emacs Org Mode] format preceded by front matter. You can use Org Mode keywords for front matter. See [details](/content-management/front-matter/#emacs-org-mode).
### AsciiDoc
@@ -39,7 +39,7 @@ weight = 10
author = 'John Smith'
{{< /code-toggle >}}
Front matter fields may be [scalar], [arrays], or [maps] containing [boolean], [integer], [float], or [string] values. Note that the TOML format also supports date/time values using unquoted strings.
Front matter fields may be [boolean], [integer], [float], [string], [arrays], or [maps]. Note that the TOML format also supports unquoted date/time values.
[scalar]: /getting-started/glossary/#scalar
[arrays]: /getting-started/glossary/#array
@@ -80,7 +80,8 @@ The field names below are reserved. For example, you cannot create a custom fiel
###### date
(`string`) The date associated with the page, typically the creation date. Note that the TOML format also supports date/time values using unquoted strings. Access this value from a template using the [`Date`] method on a `Page` object.
(`string`) The date associated with the page, typically the creation date. Note that the TOML format also supports unquoted date/time values. See the [dates](#dates) section for examples. Access this value from a template using the [`Date`] method on a `Page` object.
[`date`]: /methods/page/date/
@@ -99,7 +100,7 @@ If `true`, the page will not be rendered unless you pass the `--buildDrafts` fla
###### expiryDate
(`string`) The page expiration date. On or after the expiration date, the page will not be rendered unless you pass the `--buildExpired` flag to the `hugo` command. Note that the TOML format also supports date/time values using unquoted strings. Access this value from a template using the [`ExpiryDate`] method on a `Page` object.
(`string`) The page expiration date. On or after the expiration date, the page will not be rendered unless you pass the `--buildExpired` flag to the `hugo` command. 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 [`ExpiryDate`] method on a `Page` object.
[`expirydate`]: /methods/page/expirydate/
@@ -127,6 +128,7 @@ If `true`, the page will not be rendered unless you pass the `--buildDrafts` fla
[`keywords`]: /methods/page/keywords/
[taxonomy]: /getting-started/glossary/#taxonomy
{{% comment %}}
<!-- Added in v0.123.0 but purposefully omitted from documentation. -->
<!--
kind
@@ -138,10 +140,11 @@ kind
lang
: The language code for this page. This is usually derived from the module mount or filename.
-->
{{% /comment %}}
###### lastmod
(`string`) The date that the page was last modified. Note that the TOML format also supports date/time values using unquoted strings. Access this value from a template using the [`Lastmod`] method on a `Page` object.
(`string`) The date that the page was last modified. 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 [`Lastmod`] method on a `Page` object.
[`lastmod`]: /methods/page/date/
@@ -167,21 +170,27 @@ lang
###### menus
(`string`,`string array`, or `map`) If set, Hugo adds the page to the given menu or menus. See the [menus] page for details.
(`string`, `string array`, or `map`) If set, Hugo adds the page to the given menu or menus. See the [menus] page for details.
[menus]: /content-management/menus/#define-in-front-matter
###### modified
Alias to [lastmod](#lastmod).
###### outputs
(`string array`) The [output formats] to render.
[output formats]: /templates/output-formats/
{{% comment %}}
<!-- Added in v0.123.0 but purposefully omitted from documentation. -->
<!--
path
: The canonical page path.
-->
{{% /comment %}}
###### params
@@ -191,12 +200,20 @@ path
[page parameters]: #parameters
###### pubdate
Alias to [publishDate](#publishdate).
###### publishDate
(`string`) The page publication date. Before the publication date, the page will not be rendered unless you pass the `--buildFuture` flag to the `hugo` command. Note that the TOML format also supports date/time values using unquoted strings. Access this value from a template using the [`PublishDate`] method on a `Page` object.
(`string`) The page publication date. Before the publication date, the page will not be rendered unless you pass the `--buildFuture` flag to the `hugo` command. 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 [`PublishDate`] method on a `Page` object.
[`publishdate`]: /methods/page/publishdate/
###### published
Alias to [publishDate](#publishdate).
###### resources
(`map array`) An array of maps to provide metadata for [page resources].
@@ -242,6 +259,10 @@ path
[content type]: /getting-started/glossary/#content-type
[`type`]: /methods/page/type/
###### unpublishdate
Alias to [expirydate](#expirydate).
###### url
(`string`) Overrides the entire URL path. Applicable to regular pages and section pages. See the [URL management] page for details.
@@ -428,3 +449,15 @@ Note that you can also specify array elements on a single line:
[content format]: /content-management/formats/
[emacs org mode]: https://orgmode.org/
## Dates
When populating a date field, whether a [custom page parameter](#parameters) or one of the four predefined fields ([`date`](#date), [`expiryDate`](#expirydate), [`lastmod`](#lastmod), [`publishDate`](#publishdate)), use one of these parsable formats:
{{% include "functions/time/_common/parsable-date-time-strings.md" %}}
To override the default time zone, set the [`timeZone`](https://gohugo.io/getting-started/configuration/#timezone) in your site configuration. The order of precedence for determining the time zone is:
1. The time zone offset in the date/time string
2. The time zone specified in your site configuration
3. The `Etc/UTC` time zone
@@ -205,8 +205,6 @@ Sometimes it can be useful to create the filter chain once and then reuse it.
### Colors
{{< new-in 0.104.0 >}}
`.Colors` returns a slice of hex strings with the dominant colors in the image using a simple histogram method.
```go-html-template
+1 -1
View File
@@ -100,7 +100,7 @@ This front matter menu entry demonstrates some of the available properties:
{{< code-toggle file=content/products/software.md fm=true >}}
title = 'Software'
[[menus.main]]
[menus.main]
parent = 'Products'
weight = 20
pre = '<i class="fa-solid fa-code"></i>'
@@ -136,7 +136,7 @@ In the example above, all settings except `color` below `params` map to predefin
```go-html-template
{{ site.Title }}
{{ site.LanguageCode }}
{{ site.Language.LanguageCode }}
{{ site.Params.color }}
```
@@ -74,6 +74,26 @@ You can call shortcodes within other shortcodes by creating your own templates t
Use these embedded shortcodes as needed.
### comment
{{< new-in "0.137.1" >}}
{{% note %}}
To override Hugo's embedded `comment` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory.
[source code]: {{% eturl comment %}}
{{% /note %}}
Use the `comment` shortcode to include comments in your Markdown. Hugo excludes the encapsulated text when rendering your site.
Example usage:
```text
{{%/* comment */%}} TODO: rewrite the paragraph below. {{%/* /comment */%}}
```
Although you can call this shortcode using the `{{</* */>}}` notation, computationally it is more efficient to call it using the `{{%/* */%}}` notation as shown above.
### figure
{{% note %}}
+39 -27
View File
@@ -12,35 +12,34 @@ weight: 160
toc: true
aliases: [/content/summaries/,/content-management/content-summaries/]
---
{{% comment %}}
<!-- Do not remove the manual summary divider below. -->
<!-- If you do, you will break its first literal usage on this page. -->
{{% /comment %}}
<!--more-->
You can define a content summary manually, in front matter, or automatically. A manual content summary takes precedence over a front matter summary, and a front matter summary takes precedence over an automatic summary.
You can define a summary manually, in front matter, or automatically. A manual summary takes precedence over a front matter summary, and a front matter summary takes precedence over an automatic summary.
Review the [comparison table](#comparison) below to understand the characteristics of each summary type.
## Manual summary
Use a `<!--more-->` divider to indicate the end of the content summary. Hugo will not render the summary divider itself.
Use a `<!--more-->` divider to indicate the end of the summary. Hugo will not render the summary divider itself.
{{< code file=content/sample.md >}}
{{< code file=content/example.md >}}
+++
title: 'Example'
date: 2024-05-26T09:10:33-07:00
+++
Thénardier was not mistaken. The man was sitting there, and letting
Cosette get somewhat rested.
This is the first paragraph.
<!--more-->
The inn-keeper walked round the brushwood and presented himself
abruptly to the eyes of those whom he was in search of.
This is the second paragraph.
{{< /code >}}
When using the Emacs Org Mode [content format], use a `# more` divider to indicate the end of the content summary.
When using the Emacs Org Mode [content format], use a `# more` divider to indicate the end of the summary.
[content format]: /content-management/formats/
@@ -48,46 +47,44 @@ When using the Emacs Org Mode [content format], use a `# more` divider to indica
Use front matter to define a summary independent of content.
{{< code file=content/sample.md >}}
{{< code file=content/example.md >}}
+++
title: 'Example'
date: 2024-05-26T09:10:33-07:00
summary: 'Learn more about _Les Misérables_ by Victor Hugo.'
summary: 'This summary is independent of the content.'
+++
Thénardier was not mistaken. The man was sitting there, and letting
Cosette get somewhat rested. The inn-keeper walked round the
brushwood and presented himself abruptly to the eyes of those whom
he was in search of.
This is the first paragraph.
This is the second paragraph.
{{< /code >}}
## Automatic summary
If you have not defined the summary manually or in front matter, Hugo automatically defines the summary based on the [`summaryLength`] in your site configuration.
If you do not define the summary manually or in front matter, Hugo automatically defines the summary based on the [`summaryLength`] in your site configuration.
[`summaryLength`]: /getting-started/configuration/#summarylength
{{< code file=content/sample.md >}}
{{< code file=content/example.md >}}
+++
title: 'Example'
date: 2024-05-26T09:10:33-07:00
+++
Thénardier was not mistaken. The man was sitting there, and letting
Cosette get somewhat rested. The inn-keeper walked round the
brushwood and presented himself abruptly to the eyes of those whom
he was in search of.
This is the first paragraph.
This is the second paragraph.
This is the third paragraph.
{{< /code >}}
For example, with a `summaryLength` of 10, the automatic summary will be:
For example, with a `summaryLength` of 7, the automatic summary will be:
```text
Thénardier was not mistaken. The man was sitting there, and letting
Cosette get somewhat rested.
```html
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>
```
Note that the `summaryLength` is an approximate number of words.
## Comparison
Each summary type has different characteristics:
@@ -115,3 +112,18 @@ Render the summary in a template by calling the [`Summary`] method on a `Page` o
</div>
{{ end }}
```
## Alternative
Instead of calling the `Summary` method on a `Page` object, use the [`strings.Truncate`] function for granular control of the summary length. For example:
[`strings.Truncate`]: /functions/strings/truncate/
```go-html-template
{{ range site.RegularPages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
<div class="summary">
{{ .Content | strings.Truncate 42 }}
</div>
{{ end }}
```
+49 -12
View File
@@ -43,11 +43,45 @@ https://example.org/posts/my-first-post/
Set the `url` in front matter to override the entire path. Use this with either regular pages or section pages.
{{% note %}}
Hugo does not sanitize the `url` front matter field, allowing you to generate:
- File paths that contain characters reserved by the operating system. For example, file paths on Windows may not contain any of these [reserved characters]. Hugo throws an error if a file path includes a character reserved by the current operating system.
- URLs that contain disallowed characters. For example, the less than sign (`<`) is not allowed in a URL.
[reserved characters]: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
{{% /note %}}
If you set both `slug` and `url` in front matter, the `url` value takes precedence.
#### Include a colon
{{< new-in 0.136.0 >}}
If you need to include a colon in the `url` front matter field, escape it with backslash characters. Use one backslash if you wrap the string within single quotes, or use two backslashes if you wrap the string within double quotes. With YAML front matter, use a single backslash if you omit quotation marks.
For example, with this front matter:
{{< code-toggle file=content/example.md fm=true >}}
title: Example
url: "my\\:example"
{{< /code-toggle >}}
The resulting URL will be:
```text
https://example.org/my:example/
```
As described above, this will fail on Windows because the colon (`:`) is a reserved character.
#### File extensions
With this front matter:
{{< code-toggle file=content/posts/post-1.md fm=true >}}
title = 'My First Article'
url = '/articles/my-first-article'
url = 'articles/my-first-article'
{{< /code-toggle >}}
The resulting URL will be:
@@ -60,7 +94,7 @@ If you include a file extension:
{{< code-toggle file=content/posts/post-1.md fm=true >}}
title = 'My First Article'
url = '/articles/my-first-article.html'
url = 'articles/my-first-article.html'
{{< /code-toggle >}}
The resulting URL will be:
@@ -69,12 +103,11 @@ The resulting URL will be:
https://example.org/articles/my-first-article.html
```
In a monolingual site, a `url` value with or without a leading slash is relative to the `baseURL`.
#### Leading slashes
In a multilingual site:
With monolingual sites, `url` values with or without a leading slash are relative to the [`baseURL`]. With multilingual sites, `url` values with a leading slash are relative to the `baseURL`, and `url` values without a leading slash are relative to the `baseURL` plus the language prefix.
- A `url` value with a leading slash is relative to the `baseURL`.
- A `url` value without a leading slash is relative to the `baseURL` plus the language prefix.
[`baseURL`]: /getting-started/configuration/#baseurl
Site type|Front matter `url`|Resulting URL
:--|:--|:--
@@ -83,13 +116,11 @@ monolingual|`about`|`https://example.org/about/`
multilingual|`/about`|`https://example.org/about/`
multilingual|`about`|`https://example.org/de/about/`
If you set both `slug` and `url` in front matter, the `url` value takes precedence.
#### Permalinks tokens in front matter
{{< new-in "0.131.0" >}}
You can also use [Permalinks tokens](#tokens) in the `url` front matter. This is typically used in `cascade` sections:
You can also use [tokens](#tokens) when setting the `url` value. This is typically used in `cascade` sections:
{{< code-toggle file=content/foo/bar/_index.md fm=true >}}
title ="Bar"
@@ -246,9 +277,7 @@ public/
#### Tokens
Use these tokens when defining the URL pattern. These can both be used in the `permalinks` configuration and in the front matter [url](#permalinks-tokens-in-front-matter).
`:filename`
Use these tokens when defining the URL pattern. You can also use these tokens when setting the [`url`](#permalinks-tokens-in-front-matter) value in front matter.
`:year`
: The 4-digit year as defined in the front matter `date` field.
@@ -313,6 +342,14 @@ By default, Hugo produces pretty URLs. To generate ugly URLs, change your site c
uglyURLs = true
{{< /code-toggle >}}
You can also enable uglyURLs by section. For example, with a site that contains sections for books and films:
{{< code-toggle file=hugo >}}
[uglyURLs]
books = true
films = false
{{< /code-toggle >}}
### Post-processing
Hugo provides two mutually exclusive configuration options to alter URLs _after_ it renders a page.
+17 -3
View File
@@ -45,7 +45,7 @@ For a complete guide to contributing to Hugo, see the [Contribution Guide].
## Prerequisites
To build the extended edition of Hugo from source you must:
To build the extended or extended/deploy edition from source you must:
1. Install [Git]
1. Install [Go] version 1.23.0 or later
@@ -97,12 +97,26 @@ Step 4
: Make changes.
Step 5
: Compile and install:
: Compile and install.
To compile and install the standard edition:
```text
go install
```
To compile and install the extended edition:
```text
CGO_ENABLED=1 go install -tags extended
```
To compile and install the extended/deploy edition:
```text
CGO_ENABLED=1 go install -tags extended,withdeploy
```
Step 6
: Test your changes:
@@ -158,7 +172,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.128.0
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.137.1
```
To build and install at the latest commit on the master branch:
+18 -6
View File
@@ -85,6 +85,24 @@ Yes → Hugo is fast.
"It's an adverb, Sam. It's a lazy tool of a weak mind." (Outbreak, 1995).
{{% /note %}}
#### Level 6 headings
Level 6 headings are styled as `dt` elements. This was implemented to support a [glossary] with linkable terms.
[glossary]: /getting-started/glossary/
#### Function and method descriptions
When adding a page to the [functions] or [methods] section, begin the description with the word "Returns". With functions and methods that return a boolean value, begin the description with the phrase "Reports whether".
For example:
- `Returns the URL aliases as defined in front matter.`
- `Reports whether the given page is in the given section.`
[functions]: /functions
[methods]: /methods
#### Miscellaneous
Other guidelines to consider:
@@ -97,12 +115,6 @@ Other guidelines to consider:
- When including code samples, use short snippets that demonstrate the concept.
- The Hugo user community is global; use [basic english](https://simple.wikipedia.org/wiki/Basic_English) when possible.
#### Level 6 headings
Level 6 headings are styled as `dt` elements. This was implemented to support a [glossary] with linkable terms.
[glossary]: /getting-started/glossary/
## Code examples
Indent code by two spaces. With examples of template code, include a space after opening action delimiters, and include a space before closing action delimiters.
@@ -12,26 +12,17 @@ action:
aliases: [/functions/cond]
---
The CONTROL argument is a boolean value that indicates whether the function should return ARG1 or ARG2. If CONTROL is `true`, the function returns ARG1. Otherwise, the function returns ARG2.
If CONTROL is truthy the function returns ARG1, otherwise it returns ARG2.
```go-html-template
{{ $qty := 42 }}
{{ cond (le $qty 3) "few" "many" }} → many
```
The CONTROL argument must be either `true` or `false`. To cast a non-boolean value to boolean, pass it through the `not` operator twice.
```go-html-template
{{ cond (42 | not | not) "truthy" "falsy" }} → truthy
{{ cond ("" | not | not) "truthy" "falsy" }} → falsy
```
{{% note %}}
Unlike [ternary operators] in other languages, the `cond` function does not perform [short-circuit evaluation]. The function evaluates both ARG1 and ARG2, regardless of the CONTROL value.
Unlike [ternary operators] in other languages, the `compare.Conditional` function does not perform [short-circuit evaluation]. It evaluates both ARG1 and ARG2 regardless of the CONTROL value.
[short-circuit evaluation]: https://en.wikipedia.org/wiki/Short-circuit_evaluation
[ternary operators]: https://en.wikipedia.org/wiki/Ternary_conditional_operator
{{% /note %}}
Due to the absence of short-circuit evaluation, these examples throw an error:
+6 -6
View File
@@ -32,7 +32,7 @@ toc: true
{{ end }}
```
Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended edition, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language.
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.
@@ -42,7 +42,7 @@ Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both.
## Options
transpiler
: (`string`) The transpiler to use, either `libsass` (default) or `dartsass`. Hugo's extended edition includes the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass) below.
: (`string`) The transpiler to use, either `libsass` (default) 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) below.
targetPath
: (`string`) If not set, the transformed resource's target path will be the original path of the asset file with its extension replaced by `.css`.
@@ -141,8 +141,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file
```yaml
variables:
HUGO_VERSION: 0.128.0
DART_SASS_VERSION: 1.77.5
HUGO_VERSION: 0.137.1
DART_SASS_VERSION: 1.80.6
GIT_DEPTH: 0
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
@@ -175,8 +175,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should
```toml
[build.environment]
HUGO_VERSION = "0.128.0"
DART_SASS_VERSION = "1.77.5"
HUGO_VERSION = "0.137.1"
DART_SASS_VERSION = "1.80.6"
TZ = "America/Los_Angeles"
[build]
+4 -3
View File
@@ -16,7 +16,7 @@ toc: true
{{< new-in 0.128.0 >}}
<!-- TODO remove this admonition when feature is stable. -->
{{% todo %}}remove this admonition when feature is stable.{{% /todo %}}
{{% note %}}
This is an experimental feature pending the release of TailwindCSS v4.0.
@@ -31,9 +31,10 @@ To use this function you must install the Tailwind CSS CLI v4.0 or later. You ma
[Tailwind CSS documentation]: https://tailwindcss.com/docs/installation
{{% note %}}
Use npm to install the CLI prior to the v4.0 release of Tailwind CSS.
Prior to the release of Tailwind CSS v4.0 you must install [v4.0.0-alpha.26](https://github.com/tailwindlabs/tailwindcss/releases/tag/v4.0.0-alpha.26) or later.
`npm install --save-dev tailwindcss@next @tailwindcss/cli@next`
{{% /note %}}
## Options
@@ -54,7 +55,7 @@ skipInlineImportsNotFound
Define a [cache buster] in your site configuration:
[cache buster]: /getting-started/configuration/#configure-cache-busters
[cache buster]: /getting-started/configuration-build/#configure-cache-busters
{{< code-toggle file=hugo >}}
[[build.cachebusters]]
+1 -1
View File
@@ -11,5 +11,5 @@ action:
---
```go-html-template
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.128.0">
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.137.1">
```
+1 -1
View File
@@ -11,5 +11,5 @@ action:
---
```go-html-template
{{ hugo.Version }} → 0.128.0
{{ hugo.Version }} → 0.137.1
```
+2 -2
View File
@@ -15,9 +15,9 @@ expiryDate: 2025-06-24 # deprecated 2024-06-24
---
{{% deprecated-in 0.128.0 %}}
Use [js.Babel] instead.
Use [`js.Babel`] instead.
[js.Babel]: /functions/js/babel/
[`js.Babel`]: /functions/js/babel/
{{% /deprecated-in %}}
```go-html-template
@@ -24,7 +24,7 @@ Let's say you need to publish a file named "site.json" in the root of your publi
```json
{
"build_date": "2024-02-19T12:27:05-08:00",
"hugo_version": "0.128.0",
"hugo_version": "0.137.1",
"last_modified": "2024-02-19T12:01:42-08:00"
}
```
@@ -102,6 +102,10 @@ The [`Err`] method on a resource returned by the `resources.GetRemote` function
[`Err`]: /methods/resource/err/
{{% note %}}
Hugo does not classify an HTTP response with status code 404 as an error. In this case the function returns nil.
{{% /note %}}
```go-html-template
{{ $url := "https://broken-example.org/images/a.jpg" }}
{{ with resources.GetRemote $url }}
@@ -16,9 +16,9 @@ expiryDate: 2025-06-24 # deprecated 2024-06-24
---
{{% deprecated-in 0.128.0 %}}
Use [css.PostCSS] instead.
Use [`css.PostCSS`] instead.
[css.PostCSS]: /functions/css/postcss/
[`css.PostCSS`]: /functions/css/postcss/
{{% /deprecated-in %}}
```go-html-template
+8 -8
View File
@@ -16,9 +16,9 @@ expiryDate: 2025-06-24 # deprecated 2024-06-24
---
{{% deprecated-in 0.128.0 %}}
Use [css.Sass] instead.
Use [`css.Sass`] instead.
[css.Sass]: /functions/css/sass/
[`css.Sass`]: /functions/css/sass/
{{% /deprecated-in %}}
```go-html-template
@@ -36,7 +36,7 @@ Use [css.Sass] instead.
{{ end }}
```
Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended edition, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language.
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.
@@ -46,7 +46,7 @@ Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both.
## Options
transpiler
: (`string`) The transpiler to use, either `libsass` (default) or `dartsass`. Hugo's extended edition includes the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass) below.
: (`string`) The transpiler to use, either `libsass` (default) 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) below.
targetPath
: (`string`) If not set, the transformed resource's target path will be the original path of the asset file with its extension replaced by `.css`.
@@ -145,8 +145,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file
```yaml
variables:
HUGO_VERSION: 0.128.0
DART_SASS_VERSION: 1.77.5
HUGO_VERSION: 0.137.1
DART_SASS_VERSION: 1.80.6
GIT_DEPTH: 0
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
@@ -179,8 +179,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should
```toml
[build.environment]
HUGO_VERSION = "0.128.0"
DART_SASS_VERSION = "1.77.5"
HUGO_VERSION = "0.137.1"
DART_SASS_VERSION = "1.80.6"
TZ = "America/Los_Angeles"
[build]
+5 -4
View File
@@ -7,6 +7,7 @@ action:
aliases: [chomp]
related:
- functions/strings/Trim
- functions/strings/TrimSpace
- functions/strings/TrimLeft
- functions/strings/TrimPrefix
- functions/strings/TrimRight
@@ -19,9 +20,9 @@ aliases: [/functions/chomp]
If the argument is of type `template.HTML`, returns `template.HTML`, else returns a `string`.
```go-html-template
{{ chomp | "foo\n" }} → foo
{{ chomp | "foo\n\n" }} → foo
{{ chomp "foo\n" }} → foo
{{ chomp "foo\n\n" }} → foo
{{ chomp | "foo\r\n" }} → foo
{{ chomp | "foo\r\n\r\n" }} → foo
{{ chomp "foo\r\n" }} → foo
{{ chomp "foo\r\n\r\n" }} → foo
```
@@ -1,6 +1,6 @@
---
title: strings.ContainsNonSpace
description: Reports whether the given string contains any non-space characters as defined by Unicode's White Space property.
description: Reports whether the given string contains any non-space characters as defined by Unicode.
categories: []
keywords: []
action:
@@ -18,18 +18,12 @@ aliases: [/functions/strings.containsnonspace]
{{< new-in 0.111.0 >}}
Whitespace characters include `\t`, `\n`, `\v`, `\f`, `\r`, and characters in the [Unicode Space Separator] category.
[Unicode Space Separator]: https://www.compart.com/en/unicode/category/Zs
```go-html-template
{{ strings.ContainsNonSpace "\n" }} → false
{{ strings.ContainsNonSpace " " }} → false
{{ strings.ContainsNonSpace "\n abc" }} → true
```
Common whitespace characters include:
```text
'\t', '\n', '\v', '\f', '\r', ' '
```
See the [Unicode Character Database] for a complete list.
[Unicode Character Database]: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
+1 -38
View File
@@ -7,6 +7,7 @@ action:
aliases: [trim]
related:
- functions/strings/Chomp
- functions/strings/TrimSpace
- functions/strings/TrimLeft
- functions/strings/TrimPrefix
- functions/strings/TrimRight
@@ -19,41 +20,3 @@ aliases: [/functions/trim]
```go-html-template
{{ trim "++foo--" "+-" }} → foo
```
To remove leading and trailing newline characters and carriage returns:
```go-html-template
{{ trim "\nfoo\n" "\n\r" }} → foo
{{ trim "\n\nfoo\n\n" "\n\r" }} → foo
{{ trim "\r\nfoo\r\n" "\n\r" }} → foo
{{ trim "\r\n\r\nfoo\r\n\r\n" "\n\r" }} → foo
```
The `strings.Trim` function is commonly used in shortcodes to remove leading and trailing newlines characters and carriage returns from the content within the opening and closing shortcode tags.
For example, with this Markdown:
```text
{{</* my-shortcode */>}}
Able was I ere I saw Elba.
{{</* /my-shortcode */>}}
```
The value of `.Inner` in the shortcode template is:
```text
\nAble was I ere I saw Elba.\n
```
If authored on a Windows system the value of `.Inner` might, depending on the editor configuration, be:
```text
\r\nAble was I ere I saw Elba.\r\n
```
This construct is common in shortcode templates:
```go-html-template
{{ trim .Inner "\n\r" }}
```
@@ -8,6 +8,7 @@ action:
related:
- functions/strings/Chomp
- functions/strings/Trim
- functions/strings/TrimSpace
- functions/strings/TrimPrefix
- functions/strings/TrimRight
- functions/strings/TrimSuffix
@@ -8,6 +8,7 @@ action:
related:
- functions/strings/Chomp
- functions/strings/Trim
- functions/strings/TrimSpace
- functions/strings/TrimLeft
- functions/strings/TrimRight
- functions/strings/TrimSuffix
@@ -8,6 +8,7 @@ action:
related:
- functions/strings/Chomp
- functions/strings/Trim
- functions/strings/TrimSpace
- functions/strings/TrimLeft
- functions/strings/TrimPrefix
- functions/strings/TrimSuffix
@@ -0,0 +1,26 @@
---
title: strings.TrimSpace
description: Returns the given string, removing leading and trailing whitespace as defined by Unicode.
categories: []
keywords: []
action:
related:
- functions/strings/Chomp
- functions/strings/Trim
- functions/strings/TrimLeft
- functions/strings/TrimPrefix
- functions/strings/TrimRight
- functions/strings/TrimSuffix
returnType: string
signatures: [strings.TrimSpace INPUT]
---
{{< new-in 0.136.3 >}}
Whitespace characters include `\t`, `\n`, `\v`, `\f`, `\r`, and characters in the [Unicode Space Separator] category.
[Unicode Space Separator]: https://www.compart.com/en/unicode/category/Zs
```go-html-template
{{ strings.TrimSpace "\n\r\t foo \n\r\t" }} → foo
```
@@ -8,6 +8,7 @@ action:
related:
- functions/strings/Chomp
- functions/strings/Trim
- functions/strings/TrimSpace
- functions/strings/TrimLeft
- functions/strings/TrimPrefix
- functions/strings/TrimRight
+12 -19
View File
@@ -21,41 +21,34 @@ toc: true
Hugo provides [functions] and [methods] to format, localize, parse, compare, and manipulate date/time values. Before you can do any of these with string representations of date/time values, you must first convert them to [`time.Time`] values using the `time.AsTime` function.
```go-html-template
{{ $t := "2023-10-15T14:20:28-07:00" }}
{{ time.AsTime $t }} → 2023-10-15 14:20:28 -0700 PDT (time.Time)
{{ $t := "2023-10-15T13:18:50-07:00" }}
{{ time.AsTime $t }} → 2023-10-15 13:18:50 -0700 PDT (time.Time)
```
## Parsable strings
As shown above, the first argument must be a *parsable* string representation of a date/time value. For example:
As shown above, the first argument must be a parsable string representation of a date/time value. For example:
{{% include "functions/time/_common/parsable-date-time-strings.md" %}}
## Time zones
To override the default time zone, set the [`timeZone`] in your site configuration or provide a second argument to the `time.AsTime` function. For example:
When the parsable string does not contain a time zone offset, you can do either of the following to assign a time zone other than Etc/UTC:
```go-html-template
{{ time.AsTime "15 Oct 2023" "America/Los_Angeles" }}
```
- Provide a second argument to the `time.AsTime` function
```go-html-template
{{ time.AsTime "15 Oct 2023" "America/Chicago" }}
```
- Set the default time zone in your site configuration
{{< code-toggle file=hugo >}}
timeZone = 'America/New_York'
{{< /code-toggle >}}
The list of valid time zones may be system dependent, but should include `UTC`, `Local`, or any location in the [IANA Time Zone database].
The order of precedence for determining the time zone is:
1. The time zone offset in the date/time string
2. The time zone provide as the second argument to the `time.AsTime` function
2. The time zone provided as the second argument to the `time.AsTime` function
3. The time zone specified in your site configuration
4. The `Etc/UTC` time zone
The list of valid time zones may be system dependent, but should include `UTC`, `Local`, or any location in the [IANA Time Zone database].
[IANA Time Zone database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[`time.Time`]: https://pkg.go.dev/time#Time
[`timeZone`]: https://gohugo.io/getting-started/configuration/#timezone
[functions]: /functions/time/
[iana time zone database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[methods]: /methods/time/
+13 -5
View File
@@ -19,21 +19,29 @@ toc: true
Use the `time.Format` function with `time.Time` values:
```go-html-template
{{ $t := time.AsTime "2023-02-27T23:44:58-08:00" }}
{{ time.Format "2 Jan 2006" $t }} → 27 Feb 2023
{{ $t := time.AsTime "2023-10-15T13:18:50-07:00" }}
{{ time.Format "2 Jan 2006" $t }} → 15 Oct 2023
```
Or use `time.Format` with a *parsable* string representation of a date/time value:
Or use `time.Format` with a parsable string representation of a date/time value:
```go-html-template
{{ $t := "27 Feb 2023" }}
{{ time.Format "January 2, 2006" $t }} → February 27, 2023
{{ $t := "15 Oct 2023" }}
{{ time.Format "January 2, 2006" $t }} → October 15, 2023
```
Examples of parsable string representations:
{{% include "functions/time/_common/parsable-date-time-strings.md" %}}
To override the default time zone, set the [`timeZone`] in your site configuration. The order of precedence for determining the time zone is:
1. The time zone offset in the date/time string
2. The time zone specified in your site configuration
3. The `Etc/UTC` time zone
[`timeZone`]: https://gohugo.io/getting-started/configuration/#timezone
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}
@@ -2,13 +2,13 @@
# Do not remove front matter.
---
String representation|Time zone
Format|Time zone
:--|:--
2023-10-15T14:20:28-07:00|America/Los_Angeles
2023-10-15T13:18:50-0700|America/Los_Angeles
2023-10-15T13:18:50Z|Etc/UTC
2023-10-15T13:18:50|Etc/UTC
2023-10-15|Etc/UTC
15 Oct 2023|Etc/UTC
`2023-10-15T13:18:50-07:00`|`America/Los_Angeles`
`2023-10-15T13:18:50-0700`|`America/Los_Angeles`
`2023-10-15T13:18:50Z`|`Etc/UTC`
`2023-10-15T13:18:50`|Default is `Etc/UTC`
`2023-10-15`|Default is `Etc/UTC`
`15 Oct 2023`|Default is `Etc/UTC`
The last four examples are not fully qualified. Without a time zone offset, the time zone is set to Etc/UTC (Coordinated Universal Time).
The last three examples are not fully qualified, and default to the `Etc/UTC` time zone.
@@ -2,7 +2,7 @@
title: transform.ToMath
description: Renders a math expression using KaTeX.
categories: []
keywords: []
keywords: [math,katex]
action:
aliases: []
related:
@@ -36,7 +36,7 @@ These are a subset of the [KaTeX options].
output
: (`string`). Determines the markup language of the output. One of `html`, `mathml`, or `htmlAndMathml`. Default is `mathml`.
<!-- Indent to prevent spliting the description list. -->
{{% comment %}}Indent to prevent splitting the description list.{{% / comment %}}
With `html` and `htmlAndMathml` you must include KaTeX CSS within the `head` element of your base template. For example:
@@ -94,7 +94,7 @@ There are 3 ways to handle errors from KaTeX:
1. Let KaTeX throw an error and make the build fail. This is the default behavior.
1. Handle the error in your template. See the render hook example below.
1. Set the `throwOnError` option to `false` to make KaTeX render the expression as an error instead of throwing an error. See [options].
1. Set the `throwOnError` option to `false` to make KaTeX render the expression as an error instead of throwing an error. See [options](#options).
{{< code file=layouts/_default/_markup/render-passthrough-inline.html copy=true >}}
{{ with transform.ToMath .Inner }}
@@ -0,0 +1,88 @@
---
title: Configure build
description: Configure global build options.
categories: [getting started,fundamentals]
keywords: [build,buildStats,cache]
menu:
docs:
parent: getting-started
weight: 60
weight: 60
slug: configuration-build
toc: true
---
The `build` configuration section contains global build-related configuration options.
{{< code-toggle config=build />}}
#### buildStats
See [Configure buildStats](#configure-build-stats).
#### cachebusters
See [Configure Cache Busters](#configure-cache-busters).
#### noJSConfigInAssets
(`bool`) If `true`, turns off writing a `jsconfig.json` into your `/assets` folder with mapping of imports from running [js.Build](/hugo-pipes/js). This file is intended to help with intellisense/navigation inside code editors such as [VS Code](https://code.visualstudio.com/). Note that if you do not use `js.Build`, no file will be written.
#### useResourceCacheWhen
(`string`) When to use the cached resources in `/resources/_gen` for PostCSS and ToCSS. Valid values are `never`, `always` and `fallback`. The last value means that the cache will be tried if PostCSS/extended version is not available.
## Configure cache busters
{{< new-in 0.112.0 >}}
The `build.cachebusters` configuration option was added to support development using Tailwind 3.x's JIT compiler where a `build` configuration may look like this:
{{< code-toggle file=hugo >}}
[build]
[build.buildStats]
enable = true
[[build.cachebusters]]
source = "assets/watching/hugo_stats\\.json"
target = "styles\\.css"
[[build.cachebusters]]
source = "(postcss|tailwind)\\.config\\.js"
target = "css"
[[build.cachebusters]]
source = "assets/.*\\.(js|ts|jsx|tsx)"
target = "js"
[[build.cachebusters]]
source = "assets/.*\\.(.*)$"
target = "$1"
{{< /code-toggle >}}
When `buildStats` {{< new-in 0.115.1 >}} is enabled, Hugo writes a `hugo_stats.json` file on each build with HTML classes etc. that's used in the rendered output. Changes to this file will trigger a rebuild of the `styles.css` file. You also need to add `hugo_stats.json` to Hugo's server watcher. See [Hugo Starter Tailwind Basic](https://github.com/bep/hugo-starter-tailwind-basic) for a running example.
source
: A regexp matching file(s) relative to one of the virtual component directories in Hugo, typically `assets/...`.
target
: A regexp matching the keys in the resource cache that should be expired when `source` changes. You can use the matching regexp groups from `source` in the expression, e.g. `$1`.
## Configure build stats
{{< code-toggle config=build.buildStats />}}
{{< new-in 0.115.1 >}}
If `enable` is set to `true`, creates a `hugo_stats.json` file in the root of your project. This file contains arrays of the `class` attributes, `id` attributes, and tags of every HTML element within your published site. Use this file as data source when [removing unused CSS] from your site. This process is also known as pruning, purging, or tree shaking.
[removing unused CSS]: /hugo-pipes/postprocess/#css-purging-with-postcss
Exclude `class` attributes, `id` attributes, or tags from `hugo_stats.json` with the `disableClasses`, `disableIDs`, and `disableTags` keys.
{{% note %}}
Given that CSS purging is typically limited to production builds, place the `buildStats` object below [config/production].
[config/production]: /getting-started/configuration/#configuration-directory
Built for speed, there may be "false positive" detections (e.g., HTML elements that are not HTML elements) while parsing the published site. These "false positives" are infrequent and inconsequential.
{{% /note %}}
Due to the nature of partial server builds, new HTML entities are added while the server is running, but old values will not be removed until you restart the server or run a regular `hugo` build.
@@ -238,7 +238,7 @@ This is the default configuration for the AsciiDoc renderer:
###### attributes
(`map`) A map of key-value pairs, each a document attributes. See Asciidoctors [attributes].
(`map`) A map of key-value pairs, each a document attribute. See Asciidoctors [attributes].
[attributes]: https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#attributes-and-substitutions
@@ -228,6 +228,10 @@ See [Configure Build](#configure-build).
See [Configure File Caches](#configure-file-caches).
###### canonifyURLs
(`bool`) See [details](/content-management/urls/#canonical-urls) before enabling this feature. Default is `false`.
###### capitalizeListTitles
{{< new-in 0.123.3 >}}
@@ -246,10 +250,6 @@ For a website in a single language, define the `[[cascade]]` in [Front Matter](/
To remain consistent and prevent unexpected behavior, do not mix these strategies.
{{% /note %}}
###### canonifyURLs
(`bool`) See [details](/content-management/urls/#canonical-urls) before enabling this feature. Default is `false`.
###### cleanDestinationDir
(`bool`) When building, removes files from destination not found in static directories. Default is `false`.
@@ -288,6 +288,10 @@ To remain consistent and prevent unexpected behavior, do not mix these strategie
[kinds]: /getting-started/glossary/#page-kind
###### disableLanguages
See [disable a language](/content-management/multilingual/#disable-a-language).
###### disableLiveReload
(`bool`) Disable automatic live reloading of browser window. Default is `false`.
@@ -312,6 +316,9 @@ To remain consistent and prevent unexpected behavior, do not mix these strategie
(`bool`) Enable generation of `robots.txt` file. Default is `false`.
###### environment
(`string`) Build environment. Default is `production` when running `hugo` and `development` when running `hugo server`. See [Configuration directory](https://gohugo.io/getting-started/configuration/#configuration-directory).
###### frontmatter
See [Front matter Configuration](#configure-front-matter).
@@ -320,6 +327,22 @@ See [Front matter Configuration](#configure-front-matter).
(`bool`) If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will make `.Summary` and `.WordCount` behave correctly for CJK languages. Default is `false`.
###### ignoreCache
(`bool`) Ignore the cache directory. Default is `false`.
###### ignoreLogs
(`string slice`) A slice of message identifiers corresponding to warnings and errors you wish to suppress. See [`erroridf`] and [`warnidf`].
[`erroridf`]: /functions/fmt/erroridf/
[`warnidf`]: /functions/fmt/warnidf/
###### ignoreVendorPaths
(`string`) Ignore vendored modules that match the given [Glob] pattern within the `_vendor` directory.
[Glob]: https://github.com/gobwas/glob?tab=readme-ov-file#example]
###### imaging
See [image processing configuration](/content-management/image-processing/#imaging-configuration).
@@ -338,9 +361,9 @@ When present in the root of the configuration, this value is ignored if one or m
See [Configure Languages](/content-management/multilingual/#configure-languages).
###### disableLanguages
###### layoutDir
See [Disable a Language](/content-management/multilingual/#disable-a-language)
(`string`) The directory that contains templates. Default is `layouts`.
###### markup
@@ -366,6 +389,10 @@ Module configuration see [module configuration](/hugo-modules/configuration/).
(`string`) The editor to use when creating new content.
###### noBuildLock
(`bool`) Don't create `.hugo_build.lock` file. Default is `false`.
###### noChmod
(`bool`) Don't sync permission mode of files. Default is `false`.
@@ -386,6 +413,10 @@ See [configure page](#configure-page).
See [configure pagination](/templates/pagination/#configuration).
###### panicOnWarning
(`bool`) Whether to panic on first WARNING. Default is `false`.
###### permalinks
See [Content Management](/content-management/urls/#permalinks).
@@ -394,6 +425,18 @@ See [Content Management](/content-management/urls/#permalinks).
(`bool`) Whether to pluralize automatic list titles. Applicable to section pages. Default is `true`.
###### printI18nWarnings
(`bool`) Whether to log WARNINGs for each missing translation. Default is `false`.
###### printPathWarnings
(`bool`) Whether to log WARNINGs when Hugo publishes two or more files to the same path. Default is `false`.
###### printUnusedTemplates
(`bool`) Whether to log WARNINGs for each unused template. Default is `false`.
###### publishDir
(`string`) The directory to where Hugo will write the final static site (the HTML files etc.). Default is `public`.
@@ -414,12 +457,6 @@ See [Related Content](/content-management/related/#configure-related-content).
(`bool`) See [details](/content-management/urls/#relative-urls) before enabling this feature. Default is `false`.
###### renderSegments
{{< new-in 0.124.0 >}}
(`string slice`) A list of segments to render. If not set, everything will be rendered. This is more commonly set in a CLI flag, e.g. `hugo --renderSegments segment1,segment2`. The segment names must match the names in the [segments](#configure-segments) configuration.
###### removePathAccents
(`bool`) Removes [non-spacing marks](https://www.compart.com/en/unicode/category/Mn) from [composite characters](https://en.wikipedia.org/wiki/Precomposed_character) in content paths. Default is `false`.
@@ -428,6 +465,12 @@ See [Related Content](/content-management/related/#configure-related-content).
content/post/hügó.md → https://example.org/post/hugo/
```
###### renderSegments
{{< new-in 0.124.0 >}}
(`string slice`) A list of segments to render. If not set, everything will be rendered. This is more commonly set in a CLI flag, e.g. `hugo --renderSegments segment1,segment2`. The segment names must match the names in the [segments](#configure-segments) configuration.
###### sectionPagesMenu
See [Menus](/content-management/menus/#define-automatically).
@@ -446,14 +489,23 @@ Default [sitemap configuration](/templates/sitemap/#configuration).
###### summaryLength
(`int`) Applicable to automatic summaries, the approximate number of words to render when calling the [`Summary`] method on a `Page` object. Default is `70`.
(`int`) Applicable to [automatic summaries], the minimum number of words to render when calling the [`Summary`] method on a `Page` object. In this case the `Summary` method returns the content, truncated to the paragraph closest to the `summaryLength`.
[automatic summaries]: /content-management/summaries/#automatic-summary
[`Summary`]: /methods/page/summary/
###### taxonomies
See [Configure Taxonomies](/content-management/taxonomies#configure-taxonomies).
###### templateMetrics
(`bool`) Whether to print template execution metrics to the console. Default is `false`. See [Template metrics](/troubleshooting/performance/#template-metrics).
###### templateMetricsHints
(`bool`) Whether to print template execution improvement hints to the console. Applicable when `templateMetrics` is `true`. Default is `false`. See [Template metrics](/troubleshooting/performance/#template-metrics).
###### theme
See [module configuration](/hugo-modules/configuration/#module-configuration-imports) for how to import a theme.
@@ -468,7 +520,11 @@ See [module configuration](/hugo-modules/configuration/#module-configuration-imp
###### timeZone
(`string`) The time zone (or location), e.g. `Europe/Oslo`, used to parse front matter dates without such information and in the [`time`] function. The list of valid values may be system dependent, but should include `UTC`, `Local`, and any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
(`string`) The time zone used to parse dates without time zone offsets, including front matter date fields and values passed to the [`time.AsTime`] and [`time.Format`] template functions. The list of valid values may be system dependent, but should include `UTC`, `Local`, and any location in the [IANA Time Zone Database]. For example, `America/Los_Angeles` and `Europe/Oslo` are valid time zones.
[`time.AsTime`]: /functions/time/astime/
[`time.Format`]: /functions/time/format/
[IANA Time Zone Database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
###### title
@@ -480,7 +536,7 @@ See [module configuration](/hugo-modules/configuration/#module-configuration-imp
###### uglyURLs
(`bool`) When enabled, creates URL of the form `/filename.html` instead of `/filename/`. Default is `false`.
(`bool` or `map`) Whether to generate uglyURLs. Default is `false`. See [details](/content-management/urls/#appearance).
###### watch
@@ -546,69 +602,8 @@ These settings do not apply to the [`Next`] or [`Prev`] methods on a `Pages` obj
## Configure build
The `build` configuration section contains global build-related configuration options.
See [Configure Build](/getting-started/configuration-build/).
{{< code-toggle config=build />}}
buildStats {{< new-in 0.115.1 >}}
: When enabled, creates a `hugo_stats.json` file in the root of your project. This file contains arrays of the `class` attributes, `id` attributes, and tags of every HTML element within your published site. Use this file as data source when [removing unused CSS] from your site. This process is also known as pruning, purging, or tree shaking.
[removing unused CSS]: /hugo-pipes/postprocess/#css-purging-with-postcss
Exclude `class` attributes, `id` attributes, or tags from `hugo_stats.json` with the `disableClasses`, `disableIDs`, and `disableTags` keys.
{{% note %}}
With v0.115.0 and earlier this feature was enabled by setting `writeStats` to `true`. Although still functional, the `writeStats` key will be deprecated in a future release.
Given that CSS purging is typically limited to production builds, place the `buildStats` object below [config/production].
[config/production]: /getting-started/configuration/#configuration-directory
Built for speed, there may be "false positive" detections (e.g., HTML elements that are not HTML elements) while parsing the published site. These "false positives" are infrequent and inconsequential.
{{% /note %}}
Due to the nature of partial server builds, new HTML entities are added while the server is running, but old values will not be removed until you restart the server or run a regular `hugo` build.
cachebusters
: See [Configure Cache Busters](#configure-cache-busters)
noJSConfigInAssets
: Turn off writing a `jsconfig.json` into your `/assets` folder with mapping of imports from running [js.Build](/hugo-pipes/js). This file is intended to help with intellisense/navigation inside code editors such as [VS Code](https://code.visualstudio.com/). Note that if you do not use `js.Build`, no file will be written.
useResourceCacheWhen
: When to use the cached resources in `/resources/_gen` for PostCSS and ToCSS. Valid values are `never`, `always` and `fallback`. The last value means that the cache will be tried if PostCSS/extended version is not available.
## Configure cache busters
{{< new-in 0.112.0 >}}
The `build.cachebusters` configuration option was added to support development using Tailwind 3.x's JIT compiler where a `build` configuration may look like this:
{{< code-toggle file=hugo >}}
[build]
[build.buildStats]
enable = true
[[build.cachebusters]]
source = "assets/watching/hugo_stats\\.json"
target = "styles\\.css"
[[build.cachebusters]]
source = "(postcss|tailwind)\\.config\\.js"
target = "css"
[[build.cachebusters]]
source = "assets/.*\\.(js|ts|jsx|tsx)"
target = "js"
[[build.cachebusters]]
source = "assets/.*\\.(.*)$"
target = "$1"
{{< /code-toggle >}}
When `buildStats` {{< new-in 0.115.1 >}} is enabled, Hugo writes a `hugo_stats.json` file on each build with HTML classes etc. that's used in the rendered output. Changes to this file will trigger a rebuild of the `styles.css` file. You also need to add `hugo_stats.json` to Hugo's server watcher. See [Hugo Starter Tailwind Basic](https://github.com/bep/hugo-starter-tailwind-basic) for a running example.
source
: A regexp matching file(s) relative to one of the virtual component directories in Hugo, typically `assets/...`.
target
: A regexp matching the keys in the resource cache that should be expired when `source` changes. You can use the matching regexp groups from `source` in the expression, e.g. `$1`.
## Configure server
@@ -748,7 +743,7 @@ HUGO_NUMWORKERMULTIPLIER
## Configure with environment variables
In addition to the 3 configuration options already mentioned, configuration key-values can be defined through operating system environment variables.
Configuration key-values can be defined through operating system environment variables.
For example, the following command will effectively set a website's title on Unix-like systems:
@@ -885,7 +880,6 @@ If this is not set, Hugo will use, in order of preference:
If you want to know the current value of `cacheDir`, you can run `hugo config`, e.g: `hugo config | grep cachedir`.
[`time`]: /functions/time/astime/
[`.Site.Params`]: /method/site/params/
[directory structure]: /getting-started/directory-structure/
[lookup order]: /templates/lookup-order/
@@ -919,7 +913,7 @@ The caching in Hugo is layered:
```
Dynacache
: A in memory LRU cache that gets evicted on changes, [Cache Buster](#configure-cache-busters) matches and in low memory situations.
: A in memory LRU cache that gets evicted on changes, [Cache Buster](/getting-started/configuration-build/#configure-cache-busters) matches and in low memory situations.
HTTP Cache
: Enables HTTP cache behavior (RFC 9111) for remote resources. This works best for resources with properly set up HTTP cache headers. The HTTP cache uses the [file cache] to store and serve cached resources.
+1 -1
View File
@@ -223,7 +223,7 @@ Adaptation of a site to meet language and regional requirements. This includes t
{{< new-in 0.123.0 >}}
A page or page resource identifier derived from the file path, excluding its extension and language identifier. This value is neither a file path nor a URL. Starting with a file path relative to the content directory, Hugo determines the logical path by stripping the file extension and language identifier, converting to lower case, then replacing spaces with hyphens. <!-- You may also set this value using the `path` front matter field. --> See [examples](/methods/page/path/#examples).
A page or page resource identifier derived from the file path, excluding its extension and language identifier. This value is neither a file path nor a URL. Starting with a file path relative to the content directory, Hugo determines the logical path by stripping the file extension and language identifier, converting to lower case, then replacing spaces with hyphens. {{% comment %}}<!-- You may also set this value using the `path` front matter field. -->{{% /comment %}} See [examples](/methods/page/path/#examples).
###### map
@@ -10,7 +10,7 @@ menu:
weight: 20
toc: true
aliases: [/quickstart/,/overview/quickstart/]
minVersion: v0.112.0
minVersion: v0.128.0
---
In this tutorial you will:
@@ -24,7 +24,7 @@ In this tutorial you will:
Before you begin this tutorial you must:
1. [Install Hugo] (extended edition, {{% param "minVersion" %}} or later)
1. [Install Hugo] (extended or extended/deploy edition, {{% param "minVersion" %}} or later)
1. [Install Git]
You must also be comfortable working from the command line.
@@ -97,7 +97,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.128.0
HUGO_VERSION: 0.137.1
steps:
- name: Install Hugo CLI
run: |
@@ -27,8 +27,8 @@ Define your [CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) jobs by creating
{{< code file=.gitlab-ci.yml copy=true >}}
variables:
DART_SASS_VERSION: 1.77.5
HUGO_VERSION: 0.128.0
DART_SASS_VERSION: 1.80.6
HUGO_VERSION: 0.137.1
NODE_VERSION: 20.x
GIT_DEPTH: 0
GIT_STRATEGY: clone
@@ -101,7 +101,7 @@ Create a new file named netlify.toml in the root of your project directory. In i
{{< code file=netlify.toml >}}
[build.environment]
HUGO_VERSION = "0.128.0"
HUGO_VERSION = "0.137.1"
TZ = "America/Los_Angeles"
[build]
@@ -113,8 +113,8 @@ If your site requires Dart Sass to transpile Sass to CSS, the configuration file
{{< code file=netlify.toml >}}
[build.environment]
HUGO_VERSION = "0.128.0"
DART_SASS_VERSION = "1.77.5"
HUGO_VERSION = "0.137.1"
DART_SASS_VERSION = "1.80.6"
TZ = "America/Los_Angeles"
[build]
@@ -1,6 +1,6 @@
---
title: Hugo Deploy
description: Upload your site to GCS, S3, or Azure
description: Deploy your site directly to a Google Cloud Storage bucket, an AWS S3 bucket, or an Azure Storage container.
categories: [hosting and deployment]
keywords: [deployment,s3,gcs,azure]
menu:
@@ -11,8 +11,13 @@ weight: 20
toc: true
---
You can use the "hugo deploy" command to upload your site directly to a Google Cloud Storage (GCS) bucket, an AWS S3 bucket, and/or an Azure Storage container.
Use the `hugo deploy` command to deploy your site directly to a Google Cloud Storage bucket, an AWS S3 bucket, or an Azure Storage container
{{% note %}}
This feature requires the Hugo extended/deploy edition. See the [installation] section for details.
[installation]: /installation/
{{% /note %}}
## Assumptions
@@ -20,7 +20,7 @@ aliases: [/hugo-pipes/transform-to-css/]
## Usage
Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended edition, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language.
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.
```go-html-template
{{ $opts := dict "transpiler" "libsass" "targetPath" "css/style.css" }}
@@ -37,7 +37,7 @@ Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both.
## Options
transpiler
: (`string`) The transpiler to use, either `libsass` (default) or `dartsass`. Hugo's extended edition includes the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass) below.
: (`string`) The transpiler to use, either `libsass` (default) 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) below.
targetPath
: (`string`) If not set, the transformed resource's target path will be the original path of the asset file with its extension replaced by `.css`.
@@ -136,8 +136,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file
```yaml
variables:
HUGO_VERSION: 0.128.0
DART_SASS_VERSION: 1.77.5
HUGO_VERSION: 0.137.1
DART_SASS_VERSION: 1.80.6
GIT_DEPTH: 0
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
@@ -170,8 +170,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should
```toml
[build.environment]
HUGO_VERSION = "0.128.0"
DART_SASS_VERSION = "1.77.5"
HUGO_VERSION = "0.137.1"
DART_SASS_VERSION = "1.80.6"
TZ = "America/Los_Angeles"
[build]
@@ -2,15 +2,15 @@
# Do not remove front matter.
---
## Editions
Hugo is available in three editions: standard, extended, and extended/deploy. While the standard edition provides core functionality, the extended and extended/deploy editions offer advanced features.
Hugo is available in two editions: standard and extended. With the extended edition you can:
- Encode to the WebP format when [processing images]. You can decode WebP images with either edition.
- [Transpile Sass to CSS] using the embedded LibSass transpiler. The extended edition is not required to use the [Dart Sass] transpiler.
We recommend that you install the extended edition.
Feature|extended edition|extended/deploy edition
:--|:-:|:-:
Encode to the WebP format when [processing images]. You can decode WebP images with any edition.|:heavy_check_mark:|:heavy_check_mark:
[Transpile Sass to CSS] using the embedded LibSass transpiler. You can use the [Dart Sass] transpiler with any edition.|:heavy_check_mark:|:heavy_check_mark:
Deploy your site directly to a Google Cloud Storage bucket, an AWS S3 bucket, or an Azure Storage container. See [details].|:x:|:heavy_check_mark:
[dart sass]: /hugo-pipes/transpile-sass-to-css/#dart-sass
[processing images]: /content-management/image-processing/
[transpile sass to css]: /hugo-pipes/transpile-sass-to-css/
[details]: /hosting-and-deployment/hugo-deploy/
@@ -4,7 +4,7 @@
## Build from source
To build the extended edition of Hugo from source you must:
To build the extended or extended/deploy edition from source you must:
1. Install [Git]
1. Install [Go] version 1.20 or later
@@ -13,11 +13,22 @@ To build the extended edition of Hugo from source you must:
> The install directory is controlled by the `GOPATH` and `GOBIN` environment variables. If `GOBIN` is set, binaries are installed to that directory. If `GOPATH` is set, binaries are installed to the bin subdirectory of the first directory in the `GOPATH` list. Otherwise, binaries are installed to the bin subdirectory of the default `GOPATH` (`$HOME/go` or `%USERPROFILE%\go`).
Then build and test:
To build the standard edition:
```sh
go install github.com/gohugoio/hugo@latest
```
To build the extended edition:
```sh
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
hugo version
```
To build the extended/deploy edition:
```sh
CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latest
```
[Clang]: https://clang.llvm.org/
+5
View File
@@ -10,8 +10,13 @@ menu:
weight: 50
toc: true
---
## Editions
{{% include "installation/_common/01-editions.md" %}}
Unless your specific deployment needs require the extended/deploy edition, we recommend the extended edition.
{{% include "installation/_common/02-prerequisites.md" %}}
{{% include "installation/_common/03-prebuilt-binaries.md" %}}
+13
View File
@@ -10,8 +10,13 @@ menu:
weight: 30
toc: true
---
## Editions
{{% include "installation/_common/01-editions.md" %}}
Unless your specific deployment needs require the extended/deploy edition, we recommend the extended edition.
{{% include "installation/_common/02-prerequisites.md" %}}
{{% include "installation/_common/03-prebuilt-binaries.md" %}}
@@ -157,6 +162,14 @@ Derivatives of the [Gentoo] distribution of Linux include [Calculate Linux], [Fu
[Gentoo]: https://www.gentoo.org/
[USE]: https://packages.gentoo.org/packages/www-apps/hugo
### NixOS
The NixOS distribution of Linux includes Hugo in its package repository. To install the extended edition of Hugo:
```sh
nix-env -iA nixos.hugo
```
### openSUSE
Derivatives of the [openSUSE] distribution of Linux include [GeckoLinux], [Linux Karmada], and others. To install the extended edition of Hugo:
+5
View File
@@ -10,8 +10,13 @@ menu:
weight: 20
toc: true
---
## Editions
{{% include "installation/_common/01-editions.md" %}}
Unless your specific deployment needs require the extended/deploy edition, we recommend the extended edition.
{{% include "installation/_common/02-prerequisites.md" %}}
{{% include "installation/_common/03-prebuilt-binaries.md" %}}
+4
View File
@@ -15,8 +15,12 @@ toc: true
Hugo v0.121.1 and later require at least Windows 10 or Windows Server 2016.
{{% /note %}}
## Editions
{{% include "installation/_common/01-editions.md" %}}
Unless your specific deployment needs require the extended/deploy edition, we recommend the extended edition.
{{% include "installation/_common/02-prerequisites.md" %}}
{{% include "installation/_common/03-prebuilt-binaries.md" %}}
@@ -25,4 +25,4 @@ Applicable when using manual or automatic [content summaries], the `ContentWitho
{{ .ContentWithoutSummary }}
```
The `ContentWithoutSummary` method returns an empty string if you define the content summary in front matter.
The `ContentWithoutSummary` method returns the same as `Content` if you define the content summary in front matter.
+15 -10
View File
@@ -26,36 +26,41 @@ languageName = 'Deutsch'
weight = 2
{{< /code-toggle >}}
Lang
: (`string`) The language tag as defined by [RFC 5646].
###### Lang
(`string`) The language tag as defined by [RFC 5646].
```go-html-template
{{ .Language.Lang }} → de
```
LanguageCode
: (`string`) The language code from the site configuration. Falls back to `Lang` if not defined.
###### LanguageCode
(`string`) The language code from the site configuration. Falls back to `Lang` if not defined.
```go-html-template
{{ .Language.LanguageCode }} → de-DE
```
LanguageDirection
: (`string`) The language direction from the site configuration, either `ltr` or `rtl`.
###### LanguageDirection
(`string`) The language direction from the site configuration, either `ltr` or `rtl`.
```go-html-template
{{ .Language.LanguageDirection }} → ltr
```
LanguageName
: (`string`) The language name from the site configuration.
###### LanguageName
(`string`) The language name from the site configuration.
```go-html-template
{{ .Language.LanguageName }} → Deutsch
```
Weight
: (`int`) The language weight from the site configuration which determines its order in the slice of languages returned by the `Languages` method on a `Site` object.
###### Weight
(`int`) The language weight from the site configuration which determines its order in the slice of languages returned by the `Languages` method on a `Site` object.
```go-html-template
{{ .Language.Weight }} → 2
+1 -1
View File
@@ -10,7 +10,7 @@ action:
signatures: ['PAGE.Paginate COLLECTION [N]']
---
[Pagination] is the process of splitting a list page into two or more pagers, where each pager contains a subset of the page collection and navigation links to other pagers.
Pagination is the process of splitting a list page into two or more pagers, where each pager contains a subset of the page collection and navigation links to other pagers.
By default, the number of elements on each pager is determined by your [site configuration]. The default is `10`. Override that value by providing a second argument, an integer, when calling the `Paginate` method.
+1 -1
View File
@@ -10,7 +10,7 @@ action:
signatures: [PAGE.Paginator]
---
[Pagination] is the process of splitting a list page into two or more pagers, where each pager contains a subset of the page collection and navigation links to other pagers.
Pagination is the process of splitting a list page into two or more pagers, where each pager contains a subset of the page collection and navigation links to other pagers.
The number of elements on each pager is determined by your [site configuration]. The default is `10`.
@@ -32,9 +32,9 @@ For example:
Then call the shortcode in your Markdown:
{{< code file=content/about.md lang=md >}}
{{%/* include "/snippets/services.md" */%}}
{{%/* include "/snippets/values.md" */%}}
{{%/* include "/snippets/leadership.md" */%}}
{{%/* include "/snippets/services" */%}}
{{%/* include "/snippets/values" */%}}
{{%/* include "/snippets/leadership" */%}}
{{< /code >}}
Each of the included Markdown files can contain calls to other shortcodes.
@@ -79,3 +79,14 @@ An *emphasized* word.
```
Note that the shortcode within the content file was rendered, but the surrounding Markdown was preserved.
## Limitations
The primary use case for `.RenderShortcodes` is inclusion of Markdown content. If you try to use `.RenderShortcodes` inside `HTML` blocks when inside Markdown, you will get a warning similar to this:
```
WARN .RenderShortcodes detected inside HTML block in "/content/mypost.md"; this may not be what you intended ...
```
The above warning can be turned off is this is what you really want.
+12 -2
View File
@@ -13,6 +13,16 @@ toc: true
aliases: [/extras/scratch/,/doc/scratch/,/functions/scratch]
---
{{% deprecated-in 0.138.0 %}}
Use the [`PAGE.Store`] method instead.
This is a soft deprecation. This method will be removed in a future release, but the removal date has not been established. Although Hugo will not emit a warning if you continue to use this method, you should begin using `PAGE.Store` as soon as possible.
Beginning with v0.138.0 the `PAGE.Scratch` method is aliased to `PAGE.Store`.
[`PAGE.Store`]: /methods/page/store/
{{% /deprecated-in %}}
The `Scratch` method on a `Page` object creates a [scratch pad] to store and manipulate data. To create a scratch pad that is not reset on server rebuilds, use the [`Store`] method instead.
To create a locally scoped scratch pad that is not attached to a `Page` object, use the [`newScratch`] function.
@@ -25,7 +35,7 @@ To create a locally scoped scratch pad that is not attached to a `Page` object,
## Determinate values
The `Scratch` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are not determinate until Hugo renders the page content.
The `Scratch` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop] variable:
@@ -36,7 +46,7 @@ If you need to access a scratch pad value from a parent template, and the parent
{{ .Store.Get "mykey" }}
```
You can also trigger content rendering with the `FuzzyWordCount`, `Len`, `Plain`, `PlainWords`, `ReadingTime`, `Summary`, `Truncated`, and `WordCount` methods. For example:
You can also trigger content rendering with the `ContentWithoutSummary`, `FuzzyWordCount`, `Len`, `Plain`, `PlainWords`, `ReadingTime`, `Summary`, `Truncated`, and `WordCount` methods. For example:
```go-html-template
{{ $noop := .WordCount }}
+3 -5
View File
@@ -13,9 +13,7 @@ toc: true
aliases: [/functions/store]
---
The `Store` method on a `Page` object creates a persistent [scratch pad] to store and manipulate data. In contrast with the [`Scratch`] method, the scratch pad created by the `Store` method is not reset on server rebuilds.
To create a locally scoped scratch pad that is not attached to a `Page` object, use the [`newScratch`] function.
The `Store` method on a `Page` object creates a persistent [scratch pad] to store and manipulate data. To create a locally scoped scratch pad that is not attached to a `Page` object, use the [`newScratch`] function.
[`Scratch`]: /methods/page/scratch/
[`newScratch`]: /functions/collections/newscratch/
@@ -106,7 +104,7 @@ Removes the given key.
## Determinate values
The `Store` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are not determinate until Hugo renders the page content.
The `Store` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop] variable:
@@ -117,7 +115,7 @@ If you need to access a scratch pad value from a parent template, and the parent
{{ .Store.Get "mykey" }}
```
You can also trigger content rendering with the `FuzzyWordCount`, `Len`, `Plain`, `PlainWords`, `ReadingTime`, `Summary`, `Truncated`, and `WordCount` methods. For example:
You can also trigger content rendering with the `ContentWithoutSummary`, `FuzzyWordCount`, `Len`, `Plain`, `PlainWords`, `ReadingTime`, `Summary`, `Truncated`, and `WordCount` methods. For example:
```go-html-template
{{ $noop := .WordCount }}
+26 -8
View File
@@ -1,25 +1,27 @@
---
title: Summary
description: Returns the content summary of the given page.
description: Returns the summary of the given page.
categories: []
keywords: []
action:
related:
- methods/page/Truncated
- methods/page/Content
- methods/page/ContentWithoutSummary
- methods/page/Description
returnType: template.HTML
signatures: [PAGE.Summary]
---
<!-- Do not remove the manual summary divider below. -->
<!-- If you do, you will break its first literal usage on this page. -->
{{% comment %}}
Do not remove the manual summary divider below.
If you do, you will break its first literal usage on this page.
{{% /comment %}}
<!--more-->
There are three ways to define the [content summary]:
You can define a [summary] manually, in front matter, or automatically. A manual summary takes precedence over a front matter summary, and a front matter summary takes precedence over an automatic summary.
1. Let Hugo create the summary based on the first 70 words. You can change the number of words by setting the `summaryLength` in your site configuration.
2. Manually split the content with a `<!--more-->` tag in Markdown. Everything before the tag is included in the summary.
3. Create a `summary` field in front matter.
[summary]: /content-management/summaries/
To list the pages in a section with a summary beneath each link:
@@ -30,4 +32,20 @@ To list the pages in a section with a summary beneath each link:
{{ end }}
```
[content summary]: /content-management/summaries/
Depending on content length and how you define the summary, the summary may be equivalent to the content itself. To determine whether the content length exceeds the summary length, use the [`Truncated`] method on a `Page` object. This is useful for conditionally rendering a “read more” link:
[`Truncated`]: /methods/page/truncated
```go-html-template
{{ range .Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ .Summary }}
{{ if .Truncated }}
<a href="{{ .RelPermalink }}">Read more...</a>
{{ end }}
{{ end }}
```
{{% note %}}
The `Truncated` method returns `false` if you define the summary in front matter.
{{% /note %}}
+6 -10
View File
@@ -10,17 +10,11 @@ action:
signatures: [PAGE.Truncated]
---
There are three ways to define the [content summary]:
You can define a [summary] manually, in front matter, or automatically. A manual summary takes precedence over a front matter summary, and a front matter summary takes precedence over an automatic summary.
1. Let Hugo create the summary based on the first 70 words. You can change the number of words by setting the `summaryLength` in your site configuration.
2. Manually split the content with a `<--more-->` tag in Markdown. Everything before the tag is included in the summary.
3. Create a `summary` field in front matter.
[summary]: /content-management/summaries/
{{% note %}}
The `Truncated` method returns `false` if you define the summary in front matter.
{{% /note %}}
The `Truncated` method returns `true` if the content length exceeds the summary length. This is useful for rendering a "read more" link:
The `Truncated` method returns `true` if the content length exceeds the summary length. This is useful for conditionally rendering a "read more" link:
```go-html-template
{{ range .Pages }}
@@ -32,4 +26,6 @@ The `Truncated` method returns `true` if the content length exceeds the summary
{{ end }}
```
[content summary]: /content-management/summaries/
{{% note %}}
The `Truncated` method returns `false` if you define the summary in front matter.
{{% /note %}}
@@ -1,7 +1,6 @@
---
# Do not remove front matter.
---
Hugo generates one or more files per page when building a site. For example, when rendering home, [section], [taxonomy], and [term] pages, Hugo generates an HTML file and an RSS file. Both HTML and RSS are built-in _output formats_. Create multiple output formats, and control generation based on [page kind], or by enabling one or more output formats for one or more pages. See&nbsp;[details].
[section]: /getting-started/glossary/#section
@@ -11,8 +11,6 @@ toc: true
math: true
---
{{< new-in 0.104.0 >}}
The `Resources.Colors` method returns a slice of the most dominant colors in an image, ordered from most dominant to least dominant. This method is fast, but if you also downsize your image you can improve performance by extracting the colors from the scaled image.
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
+7 -7
View File
@@ -29,7 +29,7 @@ With this shortcode:
<div class="card-title">{{ . }}</div>
{{ end }}
<div class="card-content">
{{ trim .Inner "\r\n" }}
{{ .Inner | strings.TrimSpace }}
</div>
</div>
{{< /code >}}
@@ -46,9 +46,9 @@ Is rendered to:
```
{{% note %}}
Content between opening and closing shortcode tags may include leading and/or trailing newlines, depending on placement within the Markdown. Use the [`trim`] function as shown above to remove both carriage returns and newlines.
Content between opening and closing shortcode tags may include leading and/or trailing newlines, depending on placement within the Markdown. Use the [`strings.TrimSpace`] function as shown above to remove both carriage returns and newlines.
[`trim`]: /functions/strings/trim/
[`strings.TrimSpace`]: /functions/strings/trimspace/
{{% /note %}}
{{% note %}}
@@ -68,7 +68,7 @@ Let's modify the example above to pass the value returned by `Inner` through the
<div class="card-title">{{ . }}</div>
{{ end }}
<div class="card-content">
{{ trim .Inner "\r\n" | .Page.RenderString }}
{{ .Inner | strings.TrimSpace | .Page.RenderString }}
</div>
</div>
{{< /code >}}
@@ -119,7 +119,7 @@ Second, because we are rendering the entire shortcode as Markdown, we must adher
{{ end }}
<div class="card-content">
{{ trim .Inner "\r\n" }}
{{ .Inner | strings.TrimSpace }}
</div>
</div>
{{< /code >}}
@@ -136,9 +136,9 @@ The difference between this and the previous example is subtle but required. Not
+ <div class="card-title">{{ . }}</div>
{{ end }}
<div class="card-content">
- {{ trim .Inner "\r\n" | .Page.RenderString }}
- {{ .Inner | strings.TrimSpace | .Page.RenderString }}
+
+ {{ trim .Inner "\r\n" }}
+ {{ .Inner | strings.TrimSpace }}
</div>
</div>
```
@@ -38,7 +38,7 @@ With this shortcode, calling `Inner` instead of `InnerDeindent`:
{{< code file=layouts/shortcodes/gallery.html >}}
<div class="gallery">
{{ trim .Inner "\r\n" | .Page.RenderString }}
{{ .Inner | strings.TrimSpace | .Page.RenderString }}
</div>
{{< /code >}}
@@ -69,7 +69,7 @@ Although technically correct per the CommonMark specification, this is not what
{{< code file=layouts/shortcodes/gallery.html >}}
<div class="gallery">
{{ trim .InnerDeindent "\r\n" | .Page.RenderString }}
{{ .InnerDeindent | strings.TrimSpace | .Page.RenderString }}
</div>
{{< /code >}}
+1 -1
View File
@@ -21,7 +21,7 @@ Welcome. Today is {{</* now */>}}.
{{< code file=layouts/shortcodes/greeting.html >}}
<div class="greeting">
{{ trim .Inner "\r\n" | .Page.RenderString }}
{{ .Inner | strings.TrimSpace | .Page.RenderString }}
</div>
{{< /code >}}

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