Compare commits

...

69 Commits

Author SHA1 Message Date
hugoreleaser b2f0696cad releaser: Bump versions for release of 0.117.0
[ci skip]
2023-08-07 12:49:48 +00:00
dependabot[bot] 0de81c6430 build(deps): bump golang.org/x/net from 0.13.0 to 0.14.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.13.0 to 0.14.0.
- [Commits](https://github.com/golang/net/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 14:20:55 +02:00
Bjørn Erik Pedersen 851bf3515e Add all config to docshelper.json
Also consolidate so the mediaTypes and outputFormats are listed once only.

Fixes #11328
2023-08-07 13:42:54 +02:00
dependabot[bot] d4a6c16c17 build(deps): bump golang.org/x/image from 0.10.0 to 0.11.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.10.0 to 0.11.0.
- [Commits](https://github.com/golang/image/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 12:18:03 +02:00
Bjørn Erik Pedersen 5d5fb22ead Merge commit '7c62d6ef1654c0383eae474d3bd9ddf7754c1f30' 2023-08-07 10:38:12 +02:00
Bjørn Erik Pedersen 7c62d6ef16 Squashed 'docs/' changes from c43daf45f..a7e1e9be8
a7e1e9be8 Clarify front matter date fields
69df4fc22 Clarify how to determine if .Inner is populated
9046bf424 Document strings.ContainsNonSpace
8dbe5df90 Fix indentation and broken image
48ad4124e Typo: functions/after.md
d4c01b57b Link to detailed descriptions of canonfiyURLs and relativeURLs
4d9597302 Explain behaviour when appending to a slice containing other slices
69e24e44e Standardize right arrow usage
01b378726 Remove references to Google's Universal Analytics and the async template
d415bae24 Use shared file to describe regex syntax
e75dee6b8 snap: How to enable or revoke access to SSH keys
feed2d1c0 Remove hasPrefix and hasSuffix in favor of namespaced versions
3c6d2cfe5 security: Use default execution settings
461b5fcaf netlify: Hugo 0.116.1
95fac27a5 configuration: correct cacheDir description
cd9f1f929 configuration: Fix broken link
605394de4 netlify: Upgrade to Hugo 0.116.0
baf2a0f7b Merge branch 'tempv0.116.0'
ee51a9323 Update requirements for building from source
40189956d Editor tools: Remove duplicate sentence
fb0ff2621 docs: Regenerate CLI docs
e8a5665c4 Update where.md
7bc5cf15d Update hosting instructions
018a04314 docs: Update where
d33ae91cf docs: Update where function operators
9a108a664 docs: Rework the cacheDir documentation

git-subtree-dir: docs
git-subtree-split: a7e1e9be85
2023-08-07 10:35:12 +02:00
Bjørn Erik Pedersen 641390f8f5 Try to make test more stable 2023-08-05 11:40:18 +02:00
Bjørn Erik Pedersen 2e6191b2e0 deps: Sync go-i18n with upstream
Closes #11336
2023-08-05 11:37:04 +02:00
Bjørn Erik Pedersen 22861cb4dc Return original error on resources.GetRemote retry timeouts
See #11327
2023-08-04 21:12:04 +02:00
Bjørn Erik Pedersen 16da1ade70 testing: Write test caches to /tmp
Fixes #11327
2023-08-04 18:46:43 +02:00
Bjørn Erik Pedersen a3d42a277d Add retry in resources.GetRemote for temporary HTTP errors
Fixes #11312
2023-08-04 17:16:52 +02:00
dependabot[bot] 2c20fd557a build(deps): bump gocloud.dev from 0.24.0 to 0.33.0
Bumps [gocloud.dev](https://github.com/google/go-cloud) from 0.24.0 to 0.33.0.
- [Release notes](https://github.com/google/go-cloud/releases)
- [Commits](https://github.com/google/go-cloud/compare/v0.24.0...v0.33.0)

---
updated-dependencies:
- dependency-name: gocloud.dev
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 14:54:26 +02:00
dependabot[bot] 243736e751 build(deps): bump golang.org/x/net from 0.11.0 to 0.13.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.11.0 to 0.13.0.
- [Commits](https://github.com/golang/net/compare/v0.11.0...v0.13.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 14:53:33 +02:00
dependabot[bot] bf891c2259 build(deps): bump github.com/marekm4/color-extractor from 1.2.0 to 1.2.1
Bumps [github.com/marekm4/color-extractor](https://github.com/marekm4/color-extractor) from 1.2.0 to 1.2.1.
- [Commits](https://github.com/marekm4/color-extractor/compare/v1.2.0...v1.2.1)

---
updated-dependencies:
- dependency-name: github.com/marekm4/color-extractor
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 12:37:05 +02:00
dependabot[bot] da0df0ada3 build(deps): bump github.com/frankban/quicktest from 1.14.5 to 1.14.6
Bumps [github.com/frankban/quicktest](https://github.com/frankban/quicktest) from 1.14.5 to 1.14.6.
- [Commits](https://github.com/frankban/quicktest/compare/v1.14.5...v1.14.6)

---
updated-dependencies:
- dependency-name: github.com/frankban/quicktest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 12:36:48 +02:00
dependabot[bot] 0885f8ec2b build(deps): bump golang.org/x/image from 0.9.0 to 0.10.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/image/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 12:36:29 +02:00
dependabot[bot] 61be050a95 build(deps): bump github.com/clbanning/mxj/v2 from 2.5.7 to 2.7.0
Bumps [github.com/clbanning/mxj/v2](https://github.com/clbanning/mxj) from 2.5.7 to 2.7.0.
- [Release notes](https://github.com/clbanning/mxj/releases)
- [Commits](https://github.com/clbanning/mxj/compare/2.5.7...v2.7)

---
updated-dependencies:
- dependency-name: github.com/clbanning/mxj/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 09:54:06 +02:00
dependabot[bot] 65af75fb00 build(deps): bump golang.org/x/tools from 0.9.3 to 0.11.1
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.9.3 to 0.11.1.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.9.3...v0.11.1)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 09:53:24 +02:00
dependabot[bot] 2d75f74b86 build(deps): bump go.uber.org/automaxprocs from 1.5.2 to 1.5.3
Bumps [go.uber.org/automaxprocs](https://github.com/uber-go/automaxprocs) from 1.5.2 to 1.5.3.
- [Release notes](https://github.com/uber-go/automaxprocs/releases)
- [Changelog](https://github.com/uber-go/automaxprocs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/automaxprocs/compare/v1.5.2...v1.5.3)

---
updated-dependencies:
- dependency-name: go.uber.org/automaxprocs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 09:52:50 +02:00
dependabot[bot] 2ac3d61604 build(deps): bump github.com/hairyhenderson/go-codeowners
Bumps [github.com/hairyhenderson/go-codeowners](https://github.com/hairyhenderson/go-codeowners) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/hairyhenderson/go-codeowners/releases)
- [Commits](https://github.com/hairyhenderson/go-codeowners/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: github.com/hairyhenderson/go-codeowners
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 09:52:33 +02:00
Bjørn Erik Pedersen ade7ec8187 Add Page.RenderShortcodes
A layouts/shortcodes/include.html shortcode may look like this:

```html
{{ $p := site.GetPage (.Get 0) }}
{{ $p.RenderShortcodes }}
```

Fixes #7297
2023-08-03 20:00:57 +02:00
Joe Mooring 8fa8ce3e48 Update GitHub issue template 2023-08-02 18:07:31 +02:00
dependabot[bot] 9dce45c25d build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.8 to 2.0.9
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.8 to 2.0.9.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.8...v2.0.9)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-02 11:23:57 +02:00
hugoreleaser 239f2e2c99 releaser: Prepare repository for 0.117.0-DEV
[ci skip]
2023-08-01 07:36:32 +00:00
hugoreleaser 3e1ea030a5 releaser: Bump versions for release of 0.116.1
[ci skip]
2023-08-01 07:24:54 +00:00
Bjørn Erik Pedersen 30885a6c5f Fix module config watch regression
Fixes #11313
2023-08-01 09:05:53 +02:00
Joe Mooring 58da8554cb deps: Fix Chroma dependency version
Fixes #11311
2023-07-31 21:01:43 +02:00
hugoreleaser 92c1594372 releaser: Prepare repository for 0.117.0-DEV
[ci skip]
2023-07-31 10:40:27 +00:00
hugoreleaser 5a7e0da84e releaser: Bump versions for release of 0.116.0
[ci skip]
2023-07-31 10:28:28 +00:00
dependabot[bot] d7db096a9d build(deps): bump github.com/evanw/esbuild from 0.18.11 to 0.18.17
Bumps [github.com/evanw/esbuild](https://github.com/evanw/esbuild) from 0.18.11 to 0.18.17.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.18.11...v0.18.17)

---
updated-dependencies:
- dependency-name: github.com/evanw/esbuild
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-31 11:30:01 +02:00
Bjørn Erik Pedersen c1df5b1b0b config: Do not fail on unknown config keys
Make it a warning.

One such example I found in an old site is `blackfriday`. These should be fixed/removed, but it's not important enough
to fail the build.
2023-07-31 11:20:37 +02:00
Bjørn Erik Pedersen be8e2de597 resources: Fix spelling in method name 2023-07-30 21:12:33 +02:00
Bjørn Erik Pedersen d297c8e1b5 docs: Regenerate CLI docs 2023-07-30 18:54:08 +02:00
Bjørn Erik Pedersen fbb8eb39ec Fix so temporary images do not get published
Fixes #10255
2023-07-30 18:52:34 +02:00
Sojon 87d9bffe74 readme: Fix link 2023-07-30 11:06:31 +02:00
Joe Mooring d9fdcbe939 commands: Update cacheDir description 2023-07-29 22:09:55 +02:00
Bjørn Erik Pedersen 295d733883 Update where.md 2023-07-29 22:06:22 +02:00
Bjørn Erik Pedersen d5247788ee docs: Update where
Go doesn't use the RE2 (C++) library, it's a pure Go implementation.
2023-07-29 19:27:30 +02:00
Joe Mooring 036e260d8d docs: Update where function operators
Related to #11281
2023-07-29 16:11:53 +02:00
Bjørn Erik Pedersen a50356b9a2 docs: Rework the cacheDir documentation 2023-07-29 11:59:37 +02:00
Bjørn Erik Pedersen 8859be1c01 Merge commit '87de22d7464e239c775fbd48ebce1665d5b1e80d' 2023-07-29 11:17:28 +02:00
Bjørn Erik Pedersen 87de22d746 Squashed 'docs/' changes from 85befbb4d..c43daf45f
c43daf45f Update build-options.md
3ebbfedd4 Build options: Improve readability
5091bf6a0 Improve safeHTMLAttr explanation
b64cbce2e Fix description of collections.Apply
6ea264b9c netlify: Hugo 0.115.4
b42e7c542 Revert "config: Remove disableLiveReload"
35ce2290e Remove excess spaces in configuration docs
2edf761de Update listed titleCaseStyle default value
887f6fb97 config: Remove disableLiveReload
c9f49fb26 Fix typo
37d8569ac Remove tools associated with Atom
871d11b72 Fix URL in postprocess docs
bbb17d29f Update GitLab workflow
bc53ea5ce Use sentence-style capitalization for headings
7ca578786 netlify: Hugo 0.115.3
c5e010bd0 Merge branch 'tempv0.115.3'
c885604bf Remove starter kits page
4c0fe269e Update mention of Netlify CMS to Decap CMS
05067175c Consistently use file name instead of filename
763dd6404 Improve multilingual config example and descriptions
e5aa61ec5 Use lowercase when referring to front matter (#2132)
7ba3d0c72 docs: Refresh docs.json
de8bddedf Update description of timeout configuration value
e1245d9f8 netify: Hugo 0.115.2
153a36bdf Merge branch 'tempv0.115.2'
707cec754 Fix typo in figure example in shortcodes.md
128cbe1e5 Improve taxonomy template examples
4e743ec36 Improve highlight function example
f96fa6805 transpile sass: Fixes typo
e4a8a21f7 Compile Sass to CSS, not SCSS
c1538bd00 docs: Regenerate CLI docs
bd4e33436 Add titleCaseStyle none and firstupper
6ff93d478 Update quick-start.md
5c6653cb1 Update build config examples and explanation
1458d9a43 Remove the `url` parameter
6a1e92044 netlify: Hugo 0.115.1
a9d5d6f2f Merge branch 'tempv0.115.1'
4c4882384 docs: Regen docs helper
d1aa1c1f5 Add link to PowerShell vs Windows PowerShell documentation
6e3b70c21 Fix link to Git installation instructions
4f8a9ca38 Clarify resources.Copy arguments
ee86dd121 Update theme
dc7c305cf Update theme
60c23920b Clarify caching for resources.FromString (#2120)
5bf2fef6d netlify: Hugo 0.115.0
46bde87c5 Merge branch 'tempv0.115.0'
42cc48c16 Specify target path caching for resources.ExecuteAsTemplate (#2027)
a54bf4cd0 Correct the sample code of mermaid (#2119)
8c49b06fc docs: Update permalinks documentation
a4818d99b Page bundles: link to info about single vs. list page templates (#2116)
3fc7744d7 snap: Document removable media access
dbd08f58a Update theme
df5b88633 netlify: Hugo 0.114.1
6b859834a Fix typo
9ec92cf68 Improve Dart Sass example for Netlify
2d294ece9 Add Dart Sass installation and usage documentation
4c6b77d6c Fix placement of curly braces
897812a50 Update template-debugging.md to include a jsonify example
22bca519b Update GitHub Pages hosting instructions (#2109)
a964d93ce Document math functions new in v0.114.0 (#2108)
9f4cb040e netlify: Hugo 0.114.0
55b4d9221 Merge branch 'tempv0.114.0'
93c4dcf93 docs: Regen docshelper
96f03c77f docs: Regen CLI docs
8e22a228a Clarify resource media type variables (#2106)
2652da8d4 Update transform.Unmarshal.md (#2105)
92657177a Update theme
4601c1d65 Update theme
a216f3145 Merge commit '3c1deaf201a35de08d23cc58f8f03682cace3349'
eed8794f5 cache: Set default cache path based on $USER

git-subtree-dir: docs
git-subtree-split: c43daf45fd
2023-07-29 11:15:54 +02:00
Bjørn Erik Pedersen bec9b80d95 Deprecate taxonomyTerm
In favour of 'taxonomy'

Closes #11256
2023-07-28 15:14:24 +02:00
Bjørn Erik Pedersen 1c97095ac0 Warn about unknown kinds in disableKinds
See #11256
2023-07-28 15:14:23 +02:00
Bjørn Erik Pedersen b3cb6788b2 Move all Kind constants to its own package
See #11256
2023-07-28 15:14:23 +02:00
dependabot[bot] 5542f02fbc build(deps): bump github.com/rogpeppe/go-internal
Bumps [github.com/rogpeppe/go-internal](https://github.com/rogpeppe/go-internal) from 1.10.1-0.20230508101108-a4f6fabd84c5 to 1.11.0.
- [Release notes](https://github.com/rogpeppe/go-internal/releases)
- [Commits](https://github.com/rogpeppe/go-internal/commits/v1.11.0)

---
updated-dependencies:
- dependency-name: github.com/rogpeppe/go-internal
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-28 14:50:56 +02:00
dependabot[bot] 0bc7ed9a17 build(deps): bump golang.org/x/image from 0.8.0 to 0.9.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/image/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-28 14:49:34 +02:00
Bjørn Erik Pedersen 36b5126050 Remove unused autogenerated method 2023-07-28 10:31:37 +02:00
Oleksandr Redko 2589b1295c commands: Replace deprecated ioutil with os 2023-07-28 10:23:20 +02:00
Bjørn Erik Pedersen ef6e813ca8 tpl/collections: Add BenchmarkWhereOps
```
BenchmarkWhereOps/eq-10 	    8702	    120410 ns/op	   52280 B/op	    2515 allocs/op
BenchmarkWhereOps/ne-10 	    9829	    120759 ns/op	   52280 B/op	    2515 allocs/op
BenchmarkWhereOps/like-10           6754	    176377 ns/op	   52917 B/op	    2515 allocs/op
```
2023-07-28 10:08:13 +02:00
Joe Mooring f4598a0986 tpl/collections: Add like operator to where function
Closes #11279
2023-07-28 09:53:00 +02:00
Joe Mooring dc2a544fac tpl/collections: Fix description of apply function
The collections.Apply template function cannot be used with maps.
2023-07-28 09:51:01 +02:00
Joe Mooring 916397320b snap: Set cache location to $HOME/.cache/hugo_cache 2023-07-27 12:43:52 -07:00
Bjørn Erik Pedersen b3f10556f0 Use os.UserCacheDir as first fallback if cacheDir is not set
We will now try

1. cacheDir (or, commonly set in environment as `HUGO_CACHEDIR`)
2. if on Netlify we use `/opt/build/cache/hugo_cache/`
3. os.UserCacheDir
4. A temp dir

Storing the cache, especially the module cache, in a temporary idea has had lots of hard to debug issues, especially on MacOS,
which this commit tries to fix.

This should also make it easier to locate the Hugo cache:

>UserCacheDir returns the default root directory to use for user-specific cached data. Users should create their own
application-specific subdirectory within this one and use that.
>
>On Unix systems, it returns $XDG_CACHE_HOME as specified by
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.cache. On Darwin, it
returns $HOME/Library/Caches. On Windows, it returns %LocalAppData%. On Plan 9, it returns $home/lib/cache.
>
>If the location cannot be determined (for example, $HOME is not defined), then it will return an error.

Fixes #11286
Fixes #11291
2023-07-27 20:59:47 +02:00
Bjørn Erik Pedersen 4d7af757c9 Add a common regexp cache
```
BenchmarkGetOrCompileRegexp-10    	73959368	        13.71 ns/op	       0 B/op	       0 allocs/op
BenchmarkCompileRegexp-10         	 3143529	       380.1 ns/op	     872 B/op	      10 allocs/op
```
2023-07-27 19:23:12 +02:00
Bjørn Erik Pedersen 7f058b8bab Fix multiple languages in HUGO_DISABLELANGUAGES
Fixes #11278
2023-07-27 15:51:25 +02:00
Joe Mooring 575d7f8068 snap: Allow access to SSH keys and $HOME/.config/hugo
Closes #11288
2023-07-26 22:15:21 -07:00
Joe Mooring 739d10e8bd deps: Upgrade github.com/yuin/goldmark v1.5.4 => v1.5.5 2023-07-26 21:05:02 +02:00
hugoreleaser 0dbe0f1a07 releaser: Prepare repository for 0.116.0-DEV
[ci skip]
2023-07-20 07:02:18 +00:00
hugoreleaser dc95245212 releaser: Bump versions for release of 0.115.4
[ci skip]
2023-07-20 06:49:57 +00:00
Bjørn Erik Pedersen d70b6c7d01 Fix broken handling of legacy taxonomyTerm in disableKinds
Fixes #11257
2023-07-19 19:59:17 +02:00
Bjørn Erik Pedersen d947db3713 commands: Move testscript into its correct place 2023-07-19 19:54:36 +02:00
Bjørn Erik Pedersen d8c94c354a publisher: Improve class collector for dynamic classes
E.g.

* AlpinesJS' :class="isTrue 'class1' : 'class2'"
* And dynamic classes with colon in them, e.g. `hover:bg-white`
2023-07-19 19:50:37 +02:00
Bjørn Erik Pedersen 6bbec90014 Fix cache busting setup
By correctly capturing the target variable when compiling the cache buster.

Fixes #11268
2023-07-19 19:50:37 +02:00
Bjørn Erik Pedersen 5bd22ba85f commands: Delay server builds after the watcher is set up
See #11264
2023-07-19 19:50:37 +02:00
Bjørn Erik Pedersen 7ae62f4aa3 Create hugo_stats.json if it's mounted but does not exists
A common pattern for Tailwind 3 is to mount that file to get it on the server watch list.

A common pattern is also to add hugo_stats.json to .gitignore.

This has meant that the first time you start the server (no hugo_stats.json), it just doesn't work as expected.

Fixes #11264
2023-07-19 19:50:37 +02:00
Bjørn Erik Pedersen f1a061e9ed Re-instate disableLiveReload as a config option (and not just a flag)
Closes #11259
2023-07-19 19:50:37 +02:00
Joe Mooring 2f11e673c5 common/htime: Fix localization of abbreviated month names
Fixes #11267
2023-07-19 19:00:18 +02:00
Bjørn Erik Pedersen 387c5f60f9 Improve error messages for PostCSS etc.
Fixes #9730
2023-07-17 20:42:32 +02:00
318 changed files with 5015 additions and 3647 deletions
+6 -1
View File
@@ -5,7 +5,12 @@ assignees: ''
about: Create a report to help us improve
---
<!--
Please do not use the issue queue for questions or troubleshooting. Unless you are certain that your issue is a software defect, use the forum:
https://discourse.gohugo.io
-->
<!-- Please answer these questions before submitting your issue. Thanks! -->
### What version of Hugo are you using (`hugo version`)?
+1 -1
View File
@@ -1,4 +1,4 @@
[bep]: https://github.com/spf13
[bep]: https://github.com/bep
[bugs]: https://github.com/gohugoio/hugo/issues?q=is%3Aopen+is%3Aissue+label%3ABug
[contributing]: CONTRIBUTING.md
[create a proposal]: https://github.com/gohugoio/hugo/issues/new?labels=Proposal%2C+NeedsTriage&template=feature_request.md
+1 -1
View File
@@ -515,7 +515,7 @@ Complete documentation is available at https://gohugo.io/.`
func applyLocalFlagsBuildConfig(cmd *cobra.Command, r *rootCommand) {
cmd.Flags().StringSliceP("theme", "t", []string{}, "themes to use (located in /themes/THEMENAME/)")
cmd.Flags().StringVarP(&r.baseURL, "baseURL", "b", "", "hostname (and path) to the root, e.g. https://spf13.com/")
cmd.Flags().StringP("cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/")
cmd.Flags().StringP("cacheDir", "", "", "filesystem path to cache directory")
_ = cmd.Flags().SetAnnotation("cacheDir", cobra.BashCompSubdirsInDir, []string{})
cmd.Flags().StringP("contentDir", "c", "", "filesystem path to content directory")
_ = cmd.Flags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
+10
View File
@@ -30,6 +30,8 @@ import (
"github.com/gohugoio/hugo/docshelper"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/parser"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
@@ -197,6 +199,14 @@ url: %s
enc := json.NewEncoder(f)
enc.SetIndent("", " ")
configProvider := func() docshelper.DocProvider {
conf := hugolib.DefaultConfig()
conf.CacheDir = "" // The default value does not make sense in the docs.
defaultConfig := parser.LowerCaseCamelJSONMarshaller{Value: conf}
return docshelper.DocProvider{"config": defaultConfig}
}
docshelper.AddDocProviderFunc(configProvider)
if err := enc.Encode(docshelper.GetDocProvider()); err != nil {
return err
}
+6 -7
View File
@@ -86,13 +86,12 @@ func flagsToCfgWithAdditionalConfigBase(cd *simplecobra.Commandeer, cfg config.P
// Flags that we for some reason don't want to expose in the site config.
internalKeySet := map[string]bool{
"quiet": true,
"verbose": true,
"watch": true,
"disableLiveReload": true,
"liveReloadPort": true,
"renderToMemory": true,
"clock": true,
"quiet": true,
"verbose": true,
"watch": true,
"liveReloadPort": true,
"renderToMemory": true,
"clock": true,
}
cmd := cd.CobraCommand
+1 -1
View File
@@ -348,7 +348,7 @@ description = ""
homepage = "http://example.com/"
tags = []
features = []
min_version = "0.115.0"
min_version = "0.117.0"
[author]
name = ""
+11 -11
View File
@@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
@@ -470,14 +469,6 @@ func (c *serverCommand) Name() string {
}
func (c *serverCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args []string) error {
err := func() error {
defer c.r.timeTrack(time.Now(), "Built")
err := c.build()
return err
}()
if err != nil {
return err
}
// Watch runs its own server as part of the routine
if c.serverWatch {
@@ -501,6 +492,15 @@ func (c *serverCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, arg
}
err := func() error {
defer c.r.timeTrack(time.Now(), "Built")
err := c.build()
return err
}()
if err != nil {
return err
}
return c.serve()
}
@@ -685,9 +685,9 @@ func (c *serverCommand) createCertificates(conf *commonConfig) error {
c.tlsKeyFile = filepath.Join(keyDir, fmt.Sprintf("%s-key.pem", hostname))
// Check if the certificate already exists and is valid.
certPEM, err := ioutil.ReadFile(c.tlsCertFile)
certPEM, err := os.ReadFile(c.tlsCertFile)
if err == nil {
rootPem, err := ioutil.ReadFile(filepath.Join(mclib.GetCAROOT(), "rootCA.pem"))
rootPem, err := os.ReadFile(filepath.Join(mclib.GetCAROOT(), "rootCA.pem"))
if err == nil {
if err := c.verifyCert(rootPem, certPEM, hostname); err == nil {
c.r.Println("Using existing", c.tlsCertFile, "and", c.tlsKeyFile)
+24 -1
View File
@@ -59,11 +59,34 @@ func GetGID() uint64 {
return n
}
// IsFeatureNotAvailableError returns true if the given error is or contains a FeatureNotAvailableError.
func IsFeatureNotAvailableError(err error) bool {
return errors.Is(err, &FeatureNotAvailableError{})
}
// ErrFeatureNotAvailable denotes that a feature is unavailable.
//
// We will, at least to begin with, make some Hugo features (SCSS with libsass) optional,
// and this error is used to signal those situations.
var ErrFeatureNotAvailable = errors.New("this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information")
var ErrFeatureNotAvailable = &FeatureNotAvailableError{Cause: errors.New("this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information")}
// FeatureNotAvailableError is an error type used to signal that a feature is not available.
type FeatureNotAvailableError struct {
Cause error
}
func (e *FeatureNotAvailableError) Unwrap() error {
return e.Cause
}
func (e *FeatureNotAvailableError) Error() string {
return e.Cause.Error()
}
func (e *FeatureNotAvailableError) Is(target error) bool {
_, ok := target.(*FeatureNotAvailableError)
return ok
}
// Must panics if err != nil.
func Must(err error) {
+10
View File
@@ -14,6 +14,7 @@
package herrors
import (
"errors"
"fmt"
"testing"
@@ -34,3 +35,12 @@ func TestIsNotExist(t *testing.T) {
// os.IsNotExist returns false for wrapped errors.
c.Assert(IsNotExist(fmt.Errorf("foo: %w", afero.ErrFileNotFound)), qt.Equals, true)
}
func TestIsFeatureNotAvailableError(t *testing.T) {
c := qt.New(t)
c.Assert(IsFeatureNotAvailableError(ErrFeatureNotAvailable), qt.Equals, true)
c.Assert(IsFeatureNotAvailableError(&FeatureNotAvailableError{}), qt.Equals, true)
c.Assert(IsFeatureNotAvailableError(errors.New("asdf")), qt.Equals, false)
}
+44
View File
@@ -15,7 +15,9 @@ package hstrings
import (
"fmt"
"regexp"
"strings"
"sync"
"github.com/gohugoio/hugo/compare"
)
@@ -55,3 +57,45 @@ func EqualAny(a string, b ...string) bool {
}
return false
}
// regexpCache represents a cache of regexp objects protected by a mutex.
type regexpCache struct {
mu sync.RWMutex
re map[string]*regexp.Regexp
}
func (rc *regexpCache) getOrCompileRegexp(pattern string) (re *regexp.Regexp, err error) {
var ok bool
if re, ok = rc.get(pattern); !ok {
re, err = regexp.Compile(pattern)
if err != nil {
return nil, err
}
rc.set(pattern, re)
}
return re, nil
}
func (rc *regexpCache) get(key string) (re *regexp.Regexp, ok bool) {
rc.mu.RLock()
re, ok = rc.re[key]
rc.mu.RUnlock()
return
}
func (rc *regexpCache) set(key string, re *regexp.Regexp) {
rc.mu.Lock()
rc.re[key] = re
rc.mu.Unlock()
}
var reCache = regexpCache{re: make(map[string]*regexp.Regexp)}
// GetOrCompileRegexp retrieves a regexp object from the cache based upon the pattern.
// If the pattern is not found in the cache, the pattern is compiled and added to
// the cache.
func GetOrCompileRegexp(pattern string) (re *regexp.Regexp, err error) {
return reCache.getOrCompileRegexp(pattern)
}
+22
View File
@@ -14,6 +14,7 @@
package hstrings
import (
"regexp"
"testing"
qt "github.com/frankban/quicktest"
@@ -34,3 +35,24 @@ func TestStringEqualFold(t *testing.T) {
c.Assert(StringEqualFold(s1).Eq("b"), qt.Equals, false)
}
func TestGetOrCompileRegexp(t *testing.T) {
c := qt.New(t)
re, err := GetOrCompileRegexp(`\d+`)
c.Assert(err, qt.IsNil)
c.Assert(re.MatchString("123"), qt.Equals, true)
}
func BenchmarkGetOrCompileRegexp(b *testing.B) {
for i := 0; i < b.N; i++ {
GetOrCompileRegexp(`\d+`)
}
}
func BenchmarkCompileRegexp(b *testing.B) {
for i := 0; i < b.N; i++ {
regexp.MustCompile(`\d+`)
}
}
+83
View File
@@ -0,0 +1,83 @@
// Copyright 2022 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 htime_test
import (
"testing"
"github.com/gohugoio/hugo/hugolib"
)
// Issue #11267
func TestApplyWithContext(t *testing.T) {
t.Parallel()
files := `
-- config.toml --
defaultContentLanguage = 'it'
-- layouts/index.html --
{{ $dates := slice
"2022-01-03"
"2022-02-01"
"2022-03-02"
"2022-04-07"
"2022-05-06"
"2022-06-04"
"2022-07-03"
"2022-08-01"
"2022-09-06"
"2022-10-05"
"2022-11-03"
"2022-12-02"
}}
{{ range $dates }}
{{ . | time.Format "month: _January_ weekday: _Monday_" }}
{{ . | time.Format "month: _Jan_ weekday: _Mon_" }}
{{ end }}
`
b := hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b.AssertFileContent("public/index.html", `
month: _gennaio_ weekday: _lunedì_
month: _gen_ weekday: _lun_
month: _febbraio_ weekday: _martedì_
month: _feb_ weekday: _mar_
month: _marzo_ weekday: _mercoledì_
month: _mar_ weekday: _mer_
month: _aprile_ weekday: _giovedì_
month: _apr_ weekday: _gio_
month: _maggio_ weekday: _venerdì_
month: _mag_ weekday: _ven_
month: _giugno_ weekday: _sabato_
month: _giu_ weekday: _sab_
month: _luglio_ weekday: _domenica_
month: _lug_ weekday: _dom_
month: _agosto_ weekday: _lunedì_
month: _ago_ weekday: _lun_
month: _settembre_ weekday: _martedì_
month: _set_ weekday: _mar_
month: _ottobre_ weekday: _mercoledì_
month: _ott_ weekday: _mer_
month: _novembre_ weekday: _giovedì_
month: _nov_ weekday: _gio_
month: _dicembre_ weekday: _venerdì_
month: _dic_ weekday: _ven_
`)
}
+7 -4
View File
@@ -124,12 +124,15 @@ func (f TimeFormatter) Format(t time.Time, layout string) string {
monthIdx := t.Month() - 1 // Month() starts at 1.
dayIdx := t.Weekday()
s = strings.ReplaceAll(s, longMonthNames[monthIdx], f.ltr.MonthWide(t.Month()))
if !strings.Contains(s, f.ltr.MonthWide(t.Month())) {
if strings.Contains(layout, "January") {
s = strings.ReplaceAll(s, longMonthNames[monthIdx], f.ltr.MonthWide(t.Month()))
} else if strings.Contains(layout, "Jan") {
s = strings.ReplaceAll(s, shortMonthNames[monthIdx], f.ltr.MonthAbbreviated(t.Month()))
}
s = strings.ReplaceAll(s, longDayNames[dayIdx], f.ltr.WeekdayWide(t.Weekday()))
if !strings.Contains(s, f.ltr.WeekdayWide(t.Weekday())) {
if strings.Contains(layout, "Monday") {
s = strings.ReplaceAll(s, longDayNames[dayIdx], f.ltr.WeekdayWide(t.Weekday()))
} else if strings.Contains(layout, "Mon") {
s = strings.ReplaceAll(s, shortDayNames[dayIdx], f.ltr.WeekdayAbbreviated(t.Weekday()))
}
+2 -2
View File
@@ -17,7 +17,7 @@ package hugo
// This should be the only one.
var CurrentVersion = Version{
Major: 0,
Minor: 116,
Minor: 117,
PatchLevel: 0,
Suffix: "-DEV",
Suffix: "",
}
+10
View File
@@ -173,6 +173,7 @@ type Logger interface {
WarnCommand(command string) logg.LevelLogger
Warnf(format string, v ...any)
Warnln(v ...any)
Deprecatef(fail bool, format string, v ...any)
}
type logAdapter struct {
@@ -297,6 +298,15 @@ func (l *logAdapter) sprint(v ...any) string {
return strings.TrimRight(fmt.Sprintln(v...), "\n")
}
func (l *logAdapter) Deprecatef(fail bool, format string, v ...any) {
format = "DEPRECATED: " + format
if fail {
l.errorl.Logf(format, v...)
} else {
l.warnl.Logf(format, v...)
}
}
type logWriter struct {
l logg.LevelLogger
}
+38 -17
View File
@@ -45,6 +45,7 @@ import (
"github.com/gohugoio/hugo/output"
"github.com/gohugoio/hugo/related"
"github.com/gohugoio/hugo/resources/images"
"github.com/gohugoio/hugo/resources/kinds"
"github.com/gohugoio/hugo/resources/page"
"github.com/gohugoio/hugo/resources/page/pagemeta"
"github.com/spf13/afero"
@@ -57,12 +58,11 @@ type InternalConfig struct {
// Server mode?
Running bool
Quiet bool
Verbose bool
Clock string
Watch bool
DisableLiveReload bool
LiveReloadPort int
Quiet bool
Verbose bool
Clock string
Watch bool
LiveReloadPort int
}
// All non-params config keys for language.
@@ -240,9 +240,14 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
disabledKinds := make(map[string]bool)
for _, kind := range c.DisableKinds {
kind = strings.ToLower(kind)
if kind == "taxonomyterm" {
if newKind := kinds.IsDeprecatedAndReplacedWith(kind); newKind != "" {
logger.Deprecatef(false, "Kind %q used in disableKinds is deprecated, use %q instead.", kind, newKind)
// Legacy config.
kind = "term"
kind = newKind
}
if kinds.GetKindAny(kind) == "" {
logger.Warnf("Unknown kind %q in disableKinds configuration.", kind)
continue
}
disabledKinds[kind] = true
}
@@ -250,9 +255,17 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
isRssDisabled := disabledKinds["rss"]
outputFormats := c.OutputFormats.Config
for kind, formats := range c.Outputs {
if newKind := kinds.IsDeprecatedAndReplacedWith(kind); newKind != "" {
logger.Deprecatef(false, "Kind %q used in outputs configuration is deprecated, use %q instead.", kind, newKind)
kind = newKind
}
if disabledKinds[kind] {
continue
}
if kinds.GetKindAny(kind) == "" {
logger.Warnf("Unknown kind %q in outputs configuration.", kind)
continue
}
for _, format := range formats {
if isRssDisabled && format == "rss" {
// Legacy config.
@@ -454,6 +467,9 @@ type RootConfig struct {
// Disable the injection of the Hugo generator tag on the home page.
DisableHugoGeneratorInject bool
// Disable live reloading in server mode.
DisableLiveReload bool
// Enable replacement in Pages' Content of Emoji shortcodes with their equivalent Unicode characters.
// <docsmeta>{"identifiers": ["Content", "Unicode"] }</docsmeta>
EnableEmoji bool
@@ -727,7 +743,8 @@ func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadCon
cfg := res.Cfg
all := &Config{}
err := decodeConfigFromParams(fs, bcfg, cfg, all, nil)
err := decodeConfigFromParams(fs, logger, bcfg, cfg, all, nil)
if err != nil {
return nil, err
}
@@ -815,7 +832,7 @@ func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadCon
// Create a copy of the complete config and replace the root keys with the language specific ones.
clone := all.cloneForLang()
if err := decodeConfigFromParams(fs, bcfg, mergedConfig, clone, differentRootKeys); err != nil {
if err := decodeConfigFromParams(fs, logger, bcfg, mergedConfig, clone, differentRootKeys); err != nil {
return nil, fmt.Errorf("failed to decode config for language %q: %w", k, err)
}
if err := clone.CompileConfig(logger); err != nil {
@@ -869,6 +886,10 @@ func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadCon
bcfg.PublishDir = all.PublishDir
res.BaseConfig = bcfg
all.CommonDirs.CacheDir = bcfg.CacheDir
for _, l := range langConfigs {
l.CommonDirs.CacheDir = bcfg.CacheDir
}
cm := &Configs{
Base: all,
@@ -883,7 +904,7 @@ func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadCon
return cm, nil
}
func decodeConfigFromParams(fs afero.Fs, bcfg config.BaseConfig, p config.Provider, target *Config, keys []string) error {
func decodeConfigFromParams(fs afero.Fs, logger loggers.Logger, bcfg config.BaseConfig, p config.Provider, target *Config, keys []string) error {
var decoderSetups []decodeWeight
@@ -896,7 +917,7 @@ func decodeConfigFromParams(fs afero.Fs, bcfg config.BaseConfig, p config.Provid
if v, found := allDecoderSetups[key]; found {
decoderSetups = append(decoderSetups, v)
} else {
return fmt.Errorf("unknown config key %q", key)
logger.Warnf("Skip unknown config key %q", key)
}
}
}
@@ -933,11 +954,11 @@ func createDefaultOutputFormats(allFormats output.Formats) map[string][]string {
}
m := map[string][]string{
page.KindPage: {htmlOut.Name},
page.KindHome: defaultListTypes,
page.KindSection: defaultListTypes,
page.KindTerm: defaultListTypes,
page.KindTaxonomy: defaultListTypes,
kinds.KindPage: {htmlOut.Name},
kinds.KindHome: defaultListTypes,
kinds.KindSection: defaultListTypes,
kinds.KindTerm: defaultListTypes,
kinds.KindTaxonomy: defaultListTypes,
}
// May be disabled
+9 -4
View File
@@ -49,10 +49,11 @@ type decodeConfig struct {
}
type decodeWeight struct {
key string
decode func(decodeWeight, decodeConfig) error
getCompiler func(c *Config) configCompiler
weight int
key string
decode func(decodeWeight, decodeConfig) error
getCompiler func(c *Config) configCompiler
weight int
internalOrDeprecated bool // Hide it from the docs.
}
var allDecoderSetups = map[string]decodeWeight{
@@ -340,6 +341,7 @@ var allDecoderSetups = map[string]decodeWeight{
p.c.Author = maps.CleanConfigStringMap(p.p.GetStringMap(d.key))
return nil
},
internalOrDeprecated: true,
},
"social": {
key: "social",
@@ -347,6 +349,7 @@ var allDecoderSetups = map[string]decodeWeight{
p.c.Social = maps.CleanConfigStringMapString(p.p.GetStringMapString(d.key))
return nil
},
internalOrDeprecated: true,
},
"uglyurls": {
key: "uglyurls",
@@ -362,12 +365,14 @@ var allDecoderSetups = map[string]decodeWeight{
}
return nil
},
internalOrDeprecated: true,
},
"internal": {
key: "internal",
decode: func(d decodeWeight, p decodeConfig) error {
return mapstructure.WeakDecode(p.p.GetStringMap(d.key), &p.c.Internal)
},
internalOrDeprecated: true,
},
}
@@ -1,4 +1,4 @@
// Copyright 2021 The Hugo Authors. All rights reserved.
// Copyright 2023 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.
@@ -11,10 +11,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package config
package allconfig
import (
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/docshelper"
)
@@ -22,8 +23,11 @@ import (
func init() {
docsProvider := func() docshelper.DocProvider {
cfg := New()
for _, configRoot := range ConfigRootKeys {
cfg := config.New()
for configRoot, v := range allDecoderSetups {
if v.internalOrDeprecated {
continue
}
cfg.Set(configRoot, make(maps.Params))
}
lang := maps.Params{
@@ -38,7 +42,7 @@ func init() {
configHelpers := map[string]any{
"mergeStrategy": cfg.Get(""),
}
return docshelper.DocProvider{"config": configHelpers}
return docshelper.DocProvider{"config_helpers": configHelpers}
}
docshelper.AddDocProviderFunc(docsProvider)
+26 -5
View File
@@ -79,6 +79,7 @@ func LoadConfig(d ConfigSourceDescriptor) (*Configs, error) {
if err := configs.transientErr(); err != nil {
return nil, fmt.Errorf("failed to create config from modules config: %w", err)
}
configs.LoadingInfo.ConfigFiles = append(configs.LoadingInfo.ConfigFiles, l.ModulesConfigFiles...)
} else if err := configs.transientErr(); err != nil {
return nil, fmt.Errorf("failed to create config: %w", err)
}
@@ -297,14 +298,20 @@ func (l configLoader) applyOsEnvOverrides(environ []string) error {
if nestedKey != "" {
owner[nestedKey] = env.Value
} else {
var val any = env.Value
if _, ok := allDecoderSetups[env.Key]; ok {
var val any
key := strings.ReplaceAll(env.Key, delim, ".")
_, ok := allDecoderSetups[key]
if ok {
// A map.
val, err = metadecoders.Default.UnmarshalStringTo(env.Value, map[string]interface{}{})
if v, err := metadecoders.Default.UnmarshalStringTo(env.Value, map[string]interface{}{}); err == nil {
val = v
}
}
if err == nil {
l.cfg.Set(strings.ReplaceAll(env.Key, delim, "."), val)
if val == nil {
// A string.
val = l.envStringToVal(key, env.Value)
}
l.cfg.Set(key, val)
}
}
}
@@ -312,6 +319,20 @@ func (l configLoader) applyOsEnvOverrides(environ []string) error {
return nil
}
func (l *configLoader) envStringToVal(k, v string) any {
switch k {
case "disablekinds", "disablelanguages":
if strings.Contains(v, ",") {
return strings.Split(v, ",")
} else {
return strings.Fields(v)
}
default:
return v
}
}
func (l *configLoader) loadConfigMain(d ConfigSourceDescriptor) (config.LoadConfigResult, modules.ModulesConfig, error) {
var res config.LoadConfigResult
+9 -9
View File
@@ -148,7 +148,7 @@ func (b BuildConfig) UseResourceCache(err error) bool {
}
if b.UseResourceCacheWhen == "fallback" {
return err == herrors.ErrFeatureNotAvailable
return herrors.IsFeatureNotAvailableError(err)
}
return true
@@ -333,11 +333,11 @@ func (c *CacheBuster) CompileConfig(logger loggers.Logger) error {
}
source := c.Source
target := c.Target
sourceRe, err := regexp.Compile(source)
if err != nil {
return fmt.Errorf("failed to compile cache buster source %q: %w", c.Source, err)
}
target := c.Target
var compileErr error
debugl := logger.Logger().WithLevel(logg.LevelDebug).WithField(loggers.FieldNameCmd, "cachebuster")
@@ -353,23 +353,23 @@ func (c *CacheBuster) CompileConfig(logger loggers.Logger) error {
return nil
}
groups := m[1:]
currentTarget := target
// Replace $1, $2 etc. in target.
for i, g := range groups {
target = strings.ReplaceAll(target, fmt.Sprintf("$%d", i+1), g)
currentTarget = strings.ReplaceAll(target, fmt.Sprintf("$%d", i+1), g)
}
targetRe, err := regexp.Compile(target)
targetRe, err := regexp.Compile(currentTarget)
if err != nil {
compileErr = fmt.Errorf("failed to compile cache buster target %q: %w", target, err)
compileErr = fmt.Errorf("failed to compile cache buster target %q: %w", currentTarget, err)
return nil
}
return func(s string) bool {
match = targetRe.MatchString(s)
return func(ss string) bool {
match = targetRe.MatchString(ss)
matchString := "no match"
if match {
matchString = "match!"
}
logger.Debugf("Matching %q with target %q: %s", s, target, matchString)
logger.Debugf("Matching %q with target %q: %s", ss, currentTarget, matchString)
return match
}
+33
View File
@@ -164,3 +164,36 @@ func TestBuildConfigCacheBusters(t *testing.T) {
c.Assert(m("json"), qt.IsTrue)
}
func TestBuildConfigCacheBusterstTailwindSetup(t *testing.T) {
c := qt.New(t)
cfg := New()
cfg.Set("build", map[string]interface{}{
"cacheBusters": []map[string]string{
{
"source": "assets/watching/hugo_stats\\.json",
"target": "css",
},
{
"source": "(postcss|tailwind)\\.config\\.js",
"target": "css",
},
{
"source": "assets/.*\\.(js|ts|jsx|tsx)",
"target": "js",
},
{
"source": "assets/.*\\.(.*)$",
"target": "$1",
},
},
})
conf := DecodeBuildConfig(cfg)
l := loggers.NewDefault()
c.Assert(conf.CompileConfig(l), qt.IsNil)
m, err := conf.MatchCacheBuster(l, "assets/watching/hugo_stats.json")
c.Assert(err, qt.IsNil)
c.Assert(m("css"), qt.IsTrue)
}
-26
View File
@@ -1,26 +0,0 @@
// Copyright 2021 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 security
import (
"github.com/gohugoio/hugo/docshelper"
)
func init() {
docsProvider := func() docshelper.DocProvider {
return docshelper.DocProvider{"config": DefaultConfig.ToSecurityMap()}
}
docshelper.AddDocProviderFunc(docsProvider)
}
+1 -1
View File
@@ -1,3 +1,3 @@
### Asking Support Questions
### Asking support questions
We have an active [discussion forum](https://discourse.gohugo.io) where users and developers can ask questions. Please don't use the GitHub issue tracker to ask questions.
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

@@ -3,19 +3,20 @@
link = "https://www.linode.com/"
logo = "images/sponsors/linode-logo.svg"
utm_campaign = "hugosponsor"
bgcolor = "#ffffff"
[[banners]]
name = "CloudCannon"
link = "https://cloudcannon.com/hugo-cms/"
logo = "/images/sponsors/cloudcannon-white.svg"
utm_campaign = "HugoSponsorship"
utm_source = "sponsor"
utm_content = "gohugo"
bgcolor = "#034AD8"
[[banners]]
name = "Your Company?"
link = "https://bep.is/en/hugo-sponsor-2023-01/"
logo = "/images/sponsors/your-company.svg"
utm_campaign = "hugosponsor"
show_on_hover = true
bgcolor = "#004887"
[[banners]]
name = "Your Company?"
link = "https://bep.is/en/hugo-sponsor-2023-01/"
logo = "/images/sponsors/your-company.svg"
utm_campaign = "hugosponsor"
show_on_hover = true
bgcolor = "#004887"
bgcolor = "#4e4f4f"
@@ -23,7 +23,7 @@
class="{{ $classes_box }} o-100"
style="background-color: {{ .bgcolor }};">
{{ $query_params := .query_params | default "" }}
{{ $url := printf "%s?%s%s" .link $query_params (querify "utm_source" $utmSource "utm_medium" "banner" "utm_campaign" (.utm_campaign | default "hugosponsor")) | safeURL }}
{{ $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 }}
{{ $logo := resources.Get .logo }}
{{ if hugo.IsProduction }}
{{ $gtagID := printf "Sponsor %s %s" .name $gtag | title }}
@@ -34,7 +34,7 @@
show-on-hover
{{ end }}"
style="">
{{ $logo.Content | safeHTML }}
{{ with $logo }}{{ .Content | safeHTML }}{{ end }}
</a>
{{ else }}
<a
@@ -42,7 +42,7 @@
class="w-100 grow pa3{{ if .show_on_hover }}
show-on-hover
{{ end }}">
{{ $logo.Content | safeHTML }}
{{ with $logo }}{{ .Content | safeHTML }}{{ end }}
</a>
{{ end }}
</div>
+1 -1
View File
@@ -1 +1 @@
# github.com/gohugoio/gohugoioTheme v0.0.0-20230527124826-78bc315d7b8a
# github.com/gohugoio/gohugoioTheme v0.0.0-20230630055807-9874cd863bc5
+6 -6
View File
@@ -11,7 +11,7 @@
url = "/installation/"
[[docs]]
name = "Getting Started"
name = "Getting started"
weight = 30
identifier = "getting-started"
url = "/getting-started/"
@@ -26,7 +26,7 @@
# Core menus
[[docs]]
name = "Content Management"
name = "Content management"
weight = 50
identifier = "content-management"
post = "expanded"
@@ -53,7 +53,7 @@
[[docs]]
name = "Hugo Pipes"
weight = 90
identifier = "pipes"
identifier = "hugo-pipes"
url = "/hugo-pipes/"
[[docs]]
@@ -72,13 +72,13 @@
url = "/troubleshooting/"
[[docs]]
name = "Tools"
name = "Developer tools"
weight = 120
identifier = "tools"
identifier = "developer-tools"
url = "/tools/"
[[docs]]
name = "Hosting & Deployment"
name = "Hosting and deployment"
weight = 130
identifier = "hosting-and-deployment"
url = "/hosting-and-deployment/"
-4
View File
@@ -1,10 +1,6 @@
enableInlineShortcodes = false
[exec]
allow = ['^go$']
osEnv = ['^PATH$']
[funcs]
getenv = ['^HUGO_', '^REPOSITORY_URL$', '^BRANCH$']
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: "The worlds fastest framework for building websites"
title: The worlds fastest framework for building websites
date: 2017-03-02T12:00:00-05:00
features:
- heading: Blistering Speed
+4 -3
View File
@@ -1,14 +1,15 @@
---
title: About Hugo
linktitle: Overview
linkTitle: Overview
description: Hugo's features, roadmap, license, and motivation.
categories: []
keywords: []
menu:
docs:
identifier: about-hugo-overview
parent: about
weight: 1
weight: 1
weight: 10
weight: 10
aliases: [/about-hugo/,/docs/]
---
+5 -5
View File
@@ -1,13 +1,13 @@
---
title: The Benefits of Static Site Generators
linktitle: The Benefits of Static
title: Benefits of static site generators
linkTitle: Static site generators
description: Improved performance, security and ease of use are just a few of the reasons static site generators are so appealing.
keywords: [ssg,static,performance,security]
menu:
docs:
parent: about
weight: 30
weight: 30
weight: 40
weight: 40
---
The purpose of website generators is to render content into HTML files. Most are "dynamic site generators." That means the HTTP server---i.e., the program that sends files to the browser to be viewed---runs the generator to create a new HTML file every time an end user requests a page.
@@ -18,7 +18,7 @@ Hugo takes caching a step further and all HTML files are rendered on your comput
This has many benefits. The most noticeable is performance. HTTP servers are *very* good at sending files---so good, in fact, that you can effectively serve the same number of pages with a fraction of the memory and CPU needed for a dynamic site.
## More on Static Site Generators
## More on static site generators
* ["An Introduction to Static Site Generators", David Walsh]
* ["Hugo vs. WordPress page load speed comparison: Hugo leaves WordPress in its dust", GettingThingsTech][hugovwordpress]
+4 -4
View File
@@ -1,11 +1,11 @@
---
title: Hugo Features
title: Hugo features
description: Hugo boasts blistering speed, robust content management, and a powerful templating language making it a great fit for all kinds of static websites.
menu:
docs:
parent: about
weight: 20
weight: 20
weight: 30
weight: 30
toc: true
---
@@ -40,7 +40,7 @@ toc: true
* ["Minutes to Read"][pagevars] functionality
* ["WordCount"][pagevars] functionality
## Additional Features
## Additional features
* Integrated [Disqus] comment support
* Integrated [Google Analytics] support
+11 -11
View File
@@ -1,14 +1,14 @@
---
title: Hugo and the General Data Protection Regulation (GDPR)
linktitle: Hugo and GDPR
title: Hugo and the General Data Protection Regulation
linkTitle: Hugo and the GDPR
description: About how to configure your Hugo site to meet the new regulations.
layout: single
keywords: ["GDPR", "Privacy", "Data Protection"]
menu:
docs:
parent: about
weight: 5
weight: 5
weight: 60
weight: 60
aliases: [/privacy/,/gdpr/]
toc: true
---
@@ -17,7 +17,7 @@ toc: true
**Hugo is a static site generator. By using Hugo you are already standing on very solid ground. Static HTML files on disk are much easier to reason about compared to server and database driven web sites.**
But even static websites can integrate with external services, so from version `0.41`, Hugo provides a **Privacy Config** that covers the relevant built-in templates.
But even static websites can integrate with external services, so from version `0.41`, Hugo provides a **privacy configuration** that covers the relevant built-in templates.
Note that:
@@ -25,9 +25,9 @@ toc: true
* These settings work with the [internal templates](/templates/internal/). Some theme may contain custom templates for embedding services like Google Analytics. In that case these options have no effect.
* We will continue this work and improve this further in future Hugo versions.
## All Privacy Settings
## All privacy settings
Below are all privacy settings and their default value. These settings need to be put in your site config (e.g. `hugo.toml`).
Below are all privacy settings and their default value. These settings need to be put in your site configuration (e.g. `hugo.toml`).
{{< code-toggle file="hugo" >}}
[privacy]
@@ -54,11 +54,11 @@ disable = false
privacyEnhanced = false
{{< /code-toggle >}}
## Disable All Services
## Disable all services
An example Privacy Config that disables all the relevant services in Hugo. With this configuration, the other settings will not matter.
An example privacy configuration that disables all the relevant services in Hugo. With this configuration, the other settings will not matter.
{{< code-toggle file="hugo" >}}
{{< code-toggle file="hugo" >}}
[privacy]
[privacy.disqus]
disable = true
@@ -74,7 +74,7 @@ disable = true
disable = true
{{< /code-toggle >}}
## The Privacy Settings Explained
## The privacy settings explained
### GoogleAnalytics
+3 -4
View File
@@ -1,14 +1,13 @@
---
title: Apache License
linktitle: License
title: License
description: Hugo v0.15 and later are released under the Apache 2.0 license.
categories: ["about hugo"]
keywords: ["License","apache"]
menu:
docs:
parent: about
weight: 60
weight: 60
weight: 70
weight: 70
aliases: [/meta/license]
toc: true
---
@@ -1,18 +1,18 @@
---
title: Hugo's Security Model
title: Hugo's security model
description: A summary of Hugo's security model.
layout: single
keywords: ["Security", "Privacy"]
menu:
docs:
parent: about
weight: 4
weight: 5
weight: 50
weight: 50
aliases: [/security/]
toc: true
---
## Runtime Security
## Runtime security
Hugo produces static output, so once built, the runtime is the browser (assuming the output is HTML) and any server (API) that you integrate with.
@@ -25,7 +25,7 @@ But when developing and building your site, the runtime is the `hugo` executable
* User-defined components have read-only access to the filesystem.
* We shell out to some external binaries to support [Asciidoctor](/content-management/formats/#list-of-content-formats) and similar, but those binaries and their flags are predefined and disabled by default (see [Security Policy](#security-policy)). General functions to run arbitrary external OS commands have been [discussed](https://github.com/gohugoio/hugo/issues/796), but not implemented because of security concerns.
## Security Policy
## Security policy
Hugo has a built-in security policy that restricts access to [os/exec](https://pkg.go.dev/os/exec), remote communication and similar.
@@ -33,19 +33,19 @@ The default configuration is listed below. Any build using features not in the a
{{< code-toggle config="security" />}}
Note that these and other config settings in Hugo can be overridden by the OS environment. If you want to block all remote HTTP fetching of data:
Note that these and other configuration settings in Hugo can be overridden by the OS environment. If you want to block all remote HTTP fetching of data:
```txt
HUGO_SECURITY_HTTP_URLS=none hugo
```
## Dependency Security
## Dependency security
Hugo is built as a static binary using [Go Modules](https://github.com/golang/go/wiki/Modules) to manage its dependencies. Go Modules have several safeguards, one of them being the `go.sum` file. This is a database of the expected cryptographic checksums of all of your dependencies, including transitive dependencies.
[Hugo Modules](/hugo-modules/) is a feature built on top of the functionality of Go Modules. Like Go Modules, a Hugo project using Hugo Modules will have a `go.sum` file. We recommend that you commit this file to your version control system. The Hugo build will fail if there is a checksum mismatch, which would be an indication of [dependency tampering](https://julienrenaux.fr/2019/12/20/github-actions-security-risk/).
## Web Application Security
## Web application security
These are the security threats as defined by [OWASP](https://en.wikipedia.org/wiki/OWASP).
+5 -5
View File
@@ -5,8 +5,8 @@ layout: single
menu:
docs:
parent: about
weight: 10
weight: 10
weight: 20
weight: 20
aliases: [/overview/introduction/,/about/why-i-built-hugo/]
toc: true
---
@@ -17,15 +17,15 @@ Websites built with Hugo are extremely fast and secure. Hugo sites can be hosted
We think of Hugo as the ideal website creation tool with nearly instant build times, able to rebuild whenever a change is made.
## How Fast is Hugo?
## How fast is Hugo?
{{< youtube "CdiDYZ51a2o" >}}
## What Does Hugo Do?
## What does Hugo do?
In technical terms, Hugo takes a source directory of files and templates and uses these as input to create a complete website.
## Who Should Use Hugo?
## Who should use Hugo?
Hugo is for people that prefer writing in a text editor over a browser.
+1 -1
View File
@@ -27,7 +27,7 @@ hugo [flags]
-D, --buildDrafts include content marked as draft
-E, --buildExpired include expired content
-F, --buildFuture include content with publishdate in the future
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
--cleanDestinationDir remove files from destination not found in static directories
--clock string set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00
--config string config file (default is hugo.yaml|json|toml)
+1 -1
View File
@@ -19,7 +19,7 @@ hugo config [command] [flags]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
--format string preferred file format (toml, yaml or json) (default "toml")
-h, --help help for config
@@ -15,7 +15,7 @@ hugo config mounts [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for mounts
-t, --theme strings themes to use (located in /themes/THEMENAME/)
-4
View File
@@ -13,10 +13,6 @@ Convert your content (e.g. front matter) to different formats.
See convert's subcommands toJSON, toTOML and toYAML for more information.
```
hugo convert [command] [flags]
```
### Options
```
-4
View File
@@ -7,10 +7,6 @@ url: /commands/hugo_gen/
A collection of several useful generators.
```
hugo gen [command] [flags]
```
### Options
```
-4
View File
@@ -13,10 +13,6 @@ Import your site from other web site generators like Jekyll.
Import requires a subcommand, e.g. `hugo import jekyll jekyll_root_path target_path`.
```
hugo import [command] [flags]
```
### Options
```
-4
View File
@@ -13,10 +13,6 @@ Listing out various types of content.
List requires a subcommand, e.g. hugo list drafts
```
hugo list [command] [flags]
```
### Options
```
+1 -1
View File
@@ -20,7 +20,7 @@ hugo mod clean [flags] [args]
```
--all clean entire module cache
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for clean
--pattern string pattern matching module paths to clean (all if not set), e.g. "**hugo*"
+1 -1
View File
@@ -21,7 +21,7 @@ hugo mod graph [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
--clean delete module cache for dependencies that fail verification
-c, --contentDir string filesystem path to content directory
-h, --help help for graph
+1 -1
View File
@@ -26,7 +26,7 @@ hugo mod init [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for init
-t, --theme strings themes to use (located in /themes/THEMENAME/)
@@ -29,7 +29,7 @@ hugo mod npm pack [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for pack
-t, --theme strings themes to use (located in /themes/THEMENAME/)
+1 -1
View File
@@ -15,7 +15,7 @@ hugo mod tidy [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for tidy
-t, --theme strings themes to use (located in /themes/THEMENAME/)
+1 -1
View File
@@ -21,7 +21,7 @@ hugo mod vendor [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for vendor
-t, --theme strings themes to use (located in /themes/THEMENAME/)
+1 -1
View File
@@ -19,7 +19,7 @@ hugo mod verify [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
--clean delete module cache for dependencies that fail verification
-c, --contentDir string filesystem path to content directory
-h, --help help for verify
+1 -5
View File
@@ -18,10 +18,6 @@ If archetypes are provided in your theme or site, they will be used.
Ensure you run this within the root directory of your site.
```
hugo new [command] [flags]
```
### Options
```
@@ -50,5 +46,5 @@ hugo new [command] [flags]
* [hugo](/commands/hugo/) - hugo builds your site
* [hugo new content](/commands/hugo_new_content/) - Create new content for your site
* [hugo new site](/commands/hugo_new_site/) - Create a new site (skeleton)
* [hugo new theme](/commands/hugo_new_theme/) - Create a new site (skeleton)
* [hugo new theme](/commands/hugo_new_theme/) - Create a new theme (skeleton)
+8 -8
View File
@@ -10,13 +10,13 @@ Create new content for your site
### Synopsis
Create a new content file and automatically set the date and title.
It will guess which kind of file to create based on the path provided.
You can also specify the kind with `-k KIND`.
If archetypes are provided in your theme or site, they will be used.
Ensure you run this within the root directory of your site.
It will guess which kind of file to create based on the path provided.
You can also specify the kind with `-k KIND`.
If archetypes are provided in your theme or site, they will be used.
Ensure you run this within the root directory of your site.
```
hugo new content [path] [flags]
@@ -26,7 +26,7 @@ hugo new content [path] [flags]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
--editor string edit new content with this editor, if provided
-f, --force overwrite file if it already exists
+3 -2
View File
@@ -20,8 +20,9 @@ hugo new site [path] [flags]
### Options
```
-f, --force init inside non-empty directory
-h, --help help for site
-f, --force init inside non-empty directory
--format string preferred file format (toml, yaml or json) (default "toml")
-h, --help help for site
```
### Options inherited from parent commands
+6 -5
View File
@@ -5,16 +5,17 @@ url: /commands/hugo_new_theme/
---
## hugo new theme
Create a new site (skeleton)
Create a new theme (skeleton)
### Synopsis
Create a new site in the provided directory.
The new site will have the correct structure, but no content or theme yet.
Use `hugo new [contentPath]` to create new content.
Create a new theme (skeleton) called [name] in ./themes.
New theme is a skeleton. Please add content to the touched files. Add your
name to the copyright line in the license and adjust the theme.toml file
according to your needs.
```
hugo new theme [path] [flags]
hugo new theme [name] [flags]
```
### Options
+1 -1
View File
@@ -33,7 +33,7 @@ hugo server [command] [flags]
-D, --buildDrafts include content marked as draft
-E, --buildExpired include expired content
-F, --buildFuture include content with publishdate in the future
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
--cacheDir string filesystem path to cache directory
--cleanDestinationDir remove files from destination not found in static directories
-c, --contentDir string filesystem path to content directory
--disableBrowserError do not show build errors in the browser
+3 -2
View File
@@ -1,9 +1,10 @@
---
title: Content Management
linkTitle: Content Management Overview
title: Content management
linkTitle: Overview
description: Hugo makes managing large static sites easy with support for archetypes, content types, menus, cross references, summaries, and more.
menu:
docs:
identifier: content-management-overview
parent: content-management
weight: 10
keywords: [source, organization]
@@ -13,7 +13,7 @@ weight: 140
aliases: [/content/archetypes/]
---
## What are Archetypes?
## What are archetypes?
**Archetypes** are content template files in the [archetypes directory] of your project that contain preconfigured [front matter] and possibly also a content disposition for your website's [content types]. These will be used when you run `hugo new`.
@@ -33,7 +33,7 @@ The above will create a new content file in `content/posts/my-first-post.md` usi
The last two list items are only applicable if you use a theme and it uses the `my-theme` theme name as an example.
## Create a New Archetype Template
## Create a new archetype template
A fictional example for the section `newsletter` and the archetype file `archetypes/newsletter.md`. Create a new file in `archetypes/newsletter.md` and open it in a text editor.
@@ -46,7 +46,7 @@ draft: true
**Insert Lead paragraph here.**
## New Cool Posts
## New cool posts
{{ range first 10 ( where .Site.RegularPages "Type" "cool" ) }}
* {{ .Title }}
@@ -1,9 +1,8 @@
---
title: Build Options
linkTitle: Build Options
title: Build options
description: Build options help define how Hugo must treat a given page when building the site.
keywords: [build,content,front matter, page resources]
categories: [content management]
categories: [fundamentals,content management]
menu:
docs:
parent: content-management
@@ -13,7 +12,7 @@ weight: 70
aliases: [/content/build-options/]
---
They are stored in a reserved Front Matter object named `_build` with the following defaults:
They are stored in a reserved front matter object named `_build` with the following defaults:
{{< code-toggle >}}
_build:
@@ -26,38 +25,30 @@ _build:
If `always`, the page will be treated as a published page, holding its dedicated output files (`index.html`, etc...) and permalink.
We extended this property from a boolean to an enum in Hugo 0.76.0. Valid values are:
Valid values are:
never
: The page will not be included in any page collection.
always (default)
: The page will be rendered to disk and get a `RelPermalink` etc.
link
: The page will be not be rendered to disk, but will get a `RelPermalink`.
- `never`
: The page will not be included in any page collection.
- `always (default)`
: The page will be rendered to disk and get a `RelPermalink` etc.
- `link`
: The page will be not be rendered to disk, but will get a `RelPermalink`.
#### list
Note that we extended this property from a boolean to an enum in Hugo 0.68.0.
Valid values are:
never
: The page will not be included in any page collection.
always (default)
: The page will be included in all page collections, e.g. `site.RegularPages`, `$page.Pages`.
local
: The page will be included in any _local_ page collection, e.g. `$page.RegularPages`, `$page.Pages`. One use case for this would be to create fully navigable, but headless content sections.
If true, the page will be treated as part of the project's collections and, when appropriate, returned by Hugo's listing methods (`.Pages`, `.RegularPages` etc...).
- `never`
: The page will not be included in any page collection.
- `always (default)`
: The page will be included in all page collections, e.g. `site.RegularPages`, `.Pages`.
- `local`
: The page will be included in any _local_ page collection, e.g. `.RegularPages`, `.Pages`. One use case for this would be to create fully navigable, but headless content sections.
#### publishResources
If set to true the [Bundle's Resources](/content-management/page-bundles) will be published.
Setting this to false will still publish Resources on demand (when a resource's `.Permalink` or `.RelPermalink` is invoked from the templates) but will skip the others.
If set to `true` (default) the [Bundle's Resources](/content-management/page-bundles) will be published.
Setting this to `false` will still publish Resources on demand (when a resource's `.Permalink` or `.RelPermalink` is invoked from the templates) but will skip the others.
{{% note %}}
Any page, regardless of their build options, will always be available using the [`.GetPage`](/functions/getpage) methods.
@@ -67,7 +58,7 @@ Any page, regardless of their build options, will always be available using the
#### Not publishing a page
Project needs a "Who We Are" content file for Front Matter and body to be used by the homepage but nowhere else.
Project needs a "Who We Are" content file for front matter and body to be used by the homepage but nowhere else.
{{< code-toggle file="content/who-we-are.md" fm=true copy=false >}}
title: Who we are
@@ -2,7 +2,7 @@
title: Comments
description: Hugo ships with an internal Disqus template, but this isn't the only commenting system that will work with your new Hugo website.
keywords: [sections,content,organization]
categories: [project organization, fundamentals]
categories: [project organization]
menu:
docs:
parent: content-management
@@ -34,9 +34,9 @@ For many websites, this is enough configuration. However, you also have the opti
* `disqus_title`
* `disqus_url`
### Render Hugo's Built-in Disqus Partial Template
### Render Hugo's built-in Disqus partial template
Disqus has its own [internal template](https://gohugo.io/templates/internal/#disqus) available, to render it add the following code where you want comments to appear:
Disqus has its own [internal template](/templates/internal/#disqus) available, to render it add the following code where you want comments to appear:
```go-html-template
{{ template "_internal/disqus.html" . }}
@@ -1,6 +1,5 @@
---
title: Links and Cross References
linkTitle: Links and Cross References
title: Links and cross references
description: Shortcodes for creating links to documents.
categories: [content management]
keywords: ["cross references","references", "anchors", "urls"]
@@ -19,7 +18,7 @@ The `ref` and `relref` shortcodes display the absolute and relative permalinks t
The `ref` and `relref` shortcodes require a single parameter: the path to a content document, with or without a file extension, with or without an anchor. Paths without a leading `/` are first resolved relative to the current page, then to the remainder of the site.
```
```text
.
└── content
├── about
@@ -78,7 +77,7 @@ To link to another language version of a document, use this syntax:
{{</* relref path="document.md" lang="ja" */>}}
```
### Get another Output Format
### Get another output format
To link to another Output Format of a document, use this syntax:
@@ -12,7 +12,7 @@ weight: 50
---
{{< new-in "0.93.0" >}}
## GoAT Diagrams (Ascii)
## GoAT diagrams (Ascii)
Hugo supports [GoAT](https://github.com/bep/goat) natively. This means that this code block:
@@ -42,14 +42,14 @@ Will be rendered as:
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
```
## Mermaid Diagrams
## Mermaid diagrams
Hugo currently does not provide default templates for Mermaid diagrams. But you can easily add your own. One way to do it would be to create `layouts/_default/_markup/render-codeblock-mermaid.html`:
```go-html-template
<div class="mermaid">
<pre class="mermaid">
{{- .Inner | safeHTML }}
</div>
</pre>
{{ .Page.Store.Set "hasMermaid" true }}
```
@@ -66,7 +66,7 @@ And then include this snippet at the bottom of the content template (**Note**: b
With that you can use the `mermaid` language in Markdown code blocks:
````
````text
```mermaid
sequenceDiagram
participant Alice
@@ -82,7 +82,7 @@ sequenceDiagram
```
````
## Goat Ascii Diagram Examples
## Goat ASCII diagram examples
### Graphics
@@ -166,7 +166,7 @@ Created from <https://arthursonzogni.com/Diagon/#Tree>
```
### Sequence Diagram
### Sequence diagram
<https://arthursonzogni.com/Diagon/#Sequence>
+4 -11
View File
@@ -1,6 +1,5 @@
---
title: Content Formats
linkTitle: Content Formats
title: Content formats
description: Both HTML and Markdown are supported content formats.
categories: [content management]
keywords: [markdown,asciidoc,pandoc,content format]
@@ -34,7 +33,7 @@ The current list of content formats in Hugo:
The `markup identifier` is fetched from either the `markup` variable in front matter or from the file extension. For markup-related configuration, see [Configure Markup](/getting-started/configuration-markup/).
## External Helpers
## External helpers
Some of the formats in the table above need external helpers installed on your PC. For example, for AsciiDoc files,
Hugo will try to call the `asciidoctor` command. This means that you will have to install the associated
@@ -50,13 +49,7 @@ Hugo passes reasonable default arguments to these external helpers by default:
Because additional formats are external commands, generation performance will rely heavily on the performance of the external tool you are using. As this feature is still in its infancy, feedback is welcome.
{{% /note %}}
### External Helper AsciiDoc
[AsciiDoc](https://github.com/asciidoc/asciidoc) implementation EOLs in Jan 2020 and is no longer supported.
AsciiDoc development is being continued under [Asciidoctor](https://github.com/asciidoctor). The format AsciiDoc
remains of course. Please continue with the implementation Asciidoctor.
### External Helper Asciidoctor
### External helper Asciidoctor
The Asciidoctor community offers a wide set of tools for the AsciiDoc format that can be installed additionally to Hugo.
[See the Asciidoctor docs for installation instructions](https://asciidoctor.org/docs/install-toolchain/). Make sure that also all
@@ -113,7 +106,7 @@ parameters. Run Hugo with `-v`. You will get an output like
INFO 2019/12/22 09:08:48 Rendering book-as-pdf.adoc with C:\Ruby26-x64\bin\asciidoctor.bat using asciidoc args [--no-header-footer -r asciidoctor-html5s -b html5s -r asciidoctor-diagram --base-dir D:\prototypes\hugo_asciidoc_ddd\docs -a outdir=D:\prototypes\hugo_asciidoc_ddd\build -] ...
```
## Learn Markdown
## Learn markdown
Markdown syntax is simple enough to learn in a single sitting. The following are excellent resources to get you up and running:
@@ -1,5 +1,5 @@
---
title: Front Matter
title: Front matter
description: Hugo allows you to add front matter in yaml, toml, or json to your content files.
categories: [content management]
keywords: ["front matter", "yaml", "toml", "json", "metadata", "archetypes"]
@@ -16,7 +16,7 @@ aliases: [/content/front-matter/]
{{< youtube Yh2xKRJGff4 >}}
## Front Matter Formats
## Front matter formats
Hugo supports four formats for front matter, each with their own identifying tokens.
@@ -47,7 +47,7 @@ categories = [
slug = "spf13-vim-3-0-release-and-new-website"
{{< /code-toggle >}}
## Front Matter Variables
## Front matter variables
### Predefined
@@ -93,7 +93,7 @@ lastmod
: The datetime at which the content was last modified.
linkTitle
: Used for creating links to content; if set, Hugo defaults to using the `linktitle` before the `title`. Hugo can also [order lists of content by `linktitle`][bylinktitle].
: Used for creating links to content; if set, Hugo defaults to using the `linkTitle` before the `title`. Hugo can also [order lists of content by `linkTitle`][bylinktitle].
markup
: **experimental**; specify `"rst"` for reStructuredText (requires`rst2html`) or `"md"` (default) for Markdown.
@@ -135,10 +135,10 @@ weight
: Field name of the *plural* form of the index. See `tags` and `categories` in the above front matter examples. *Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables.*
{{% note %}}
If neither `slug` nor `url` is present and [permalinks are not configured otherwise in your site configuration file](/content-management/urls/#permalinks), Hugo will use the filename of your content to create the output URL. See [Content Organization](/content-management/organization) for an explanation of paths in Hugo and [URL Management](/content-management/urls/) for ways to customize Hugo's default behaviors.
If neither `slug` nor `url` is present and [permalinks are not configured otherwise in your site configuration file](/content-management/urls/#permalinks), Hugo will use the file name of your content to create the output URL. See [Content Organization](/content-management/organization) for an explanation of paths in Hugo and [URL Management](/content-management/urls/) for ways to customize Hugo's default behaviors.
{{% /note %}}
### User-Defined
### User-defined
You can add fields to your front matter arbitrarily to meet your needs. These user-defined key-values are placed into a single `.Params` variable for use in your templates.
@@ -149,11 +149,11 @@ include_toc: true
show_comments: false
{{</ code-toggle >}}
## Front Matter Cascade
## Front matter cascade
Any node or section can pass down to descendants a set of Front Matter values as long as defined underneath the reserved `cascade` Front Matter key.
Any node or section can pass down to descendants a set of front matter values as long as defined underneath the reserved `cascade` front matter key.
### Target Specific Pages
### Target specific pages
The `cascade` block can be a slice with a optional `_target` keyword, allowing for multiple `cascade` values targeting different page sets.
@@ -202,15 +202,15 @@ With the above example the Blog section page and its descendants will return `im
- Said descendant has its own `banner` value set
- Or a closer ancestor node has its own `cascade.banner` value set.
## Order Content Through Front Matter
## Order content through front matter
You can assign content-specific `weight` in the front matter of your content. These values are especially useful for [ordering][ordering] in list views. You can use `weight` for ordering of content and the convention of [`<TAXONOMY>_weight`][taxweight] for ordering content within a taxonomy. See [Ordering and Grouping Hugo Lists][lists] to see how `weight` can be used to organize your content in list views.
## Override Global Markdown Configuration
## Override global markdown configuration
It's possible to set some options for Markdown rendering in a content's front matter as an override to the [Rendering options set in your project configuration][config].
It's possible to set some options for Markdown rendering in a content's front matter as an override to the [rendering options set in your project configuration][config].
## Front Matter Format Specs
## Front matter format specs
- [TOML Spec][toml]
- [YAML Spec][yaml]
@@ -220,15 +220,15 @@ It's possible to set some options for Markdown rendering in a content's front ma
[aliases]: /content-management/urls/#aliases
[archetype]: /content-management/archetypes/
[bylinktitle]: /templates/lists/#by-link-title
[config]: /getting-started/configuration/ "Hugo documentation for site configuration"
[config]: /getting-started/configuration/
[content type]: /content-management/types/
[contentorg]: /content-management/organization/
[headless-bundle]: /content-management/page-bundles/#headless-bundle
[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation"
[lists]: /templates/lists/#order-content "See how to order content in list pages; for example, templates that look to specific _index.md for content and front matter."
[lookup]: /templates/lookup-order/ "Hugo traverses your templates in a specific order when rendering content to allow for DRYer templating."
[ordering]: /templates/lists/ "Hugo provides multiple ways to sort and order your content in list templates"
[outputs]: /templates/output-formats/ "With the release of v22, you can output your content to any text format using Hugo's familiar templating"
[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
[lists]: /templates/lists/#order-content
[lookup]: /templates/lookup-order/
[ordering]: /templates/lists/
[outputs]: /templates/output-formats/
[page-resources]: /content-management/page-resources/
[pagevars]: /variables/page/
[section]: /content-management/sections/
@@ -236,4 +236,4 @@ It's possible to set some options for Markdown rendering in a content's front ma
[toml]: https://toml.io/
[urls]: /content-management/urls/
[variables]: /variables/
[yaml]: https://yaml.org/spec/ "Specification for YAML, YAML Ain't Markup Language"
[yaml]: https://yaml.org/spec/
@@ -1,7 +1,7 @@
---
title: Image Processing
title: Image processing
description: Resize, crop, rotate, filter, and convert images.
categories: [content management]
categories: [fundamentals,content management]
keywords: [resources, images]
menu:
docs:
@@ -10,11 +10,11 @@ menu:
toc: true
weight: 90
---
## Image Resources
## Image resources
To process an image, you must access the image as either a page resource or a global resource.
### Page Resources
### Page resources
A page resource is a file within a [page bundle]. A page bundle is a directory with an `index.md` or `_index.md` file at its root.
@@ -26,7 +26,7 @@ content/
└── sunset.jpg <-- page resource
```
### Global Resources
### Global resources
A global resource is a file:
@@ -52,7 +52,7 @@ To access a remote image as a global resource:
{{ $image := resources.GetRemote "https://gohugo.io/img/hugo-logo.png" }}
```
## Image Rendering
## Image rendering
Once you have accessed an image as either a page resource or a global resource, render it in your templates using the `Permalink`, `RelPermalink`, `Width`, and `Height` properties.
@@ -80,12 +80,12 @@ Example 3: A more concise way to skip image rendering if the resource is not fou
{{ end }}
```
## Image Processing Methods
## Image processing methods
The `image` resource implements the [`Resize`], [`Fit`], [`Fill`], [`Crop`], [`Filter`], [`Colors`] and [`Exif`] methods.
{{% note %}}
Metadata (Exif, IPTC, XMP, etc.) is not preserved during image transformation. Use the [`Exif`] method with the _original_ image to extract Exif metadata from JPEG or TIFF images.
Metadata (EXIF, IPTC, XMP, etc.) is not preserved during image transformation. Use the [`Exif`] method with the _original_ image to extract EXIF metadata from JPEG or TIFF images.
{{% /note %}}
### Resize
@@ -164,11 +164,11 @@ Sometimes it can be useful to create the filter chain once and then reuse it.
This method is fast, but if you also scale down your images, it would be good for performance to extract the colors from the scaled down image.
### Exif
### EXIF
Provides an [Exif] object containing image metadata.
Provides an [EXIF] object containing image metadata.
You may access Exif data in JPEG and TIFF images. To prevent errors when processing images without Exif data, wrap the access in a [`with`] statement.
You may access EXIF data in JPEG and TIFF images. To prevent errors when processing images without EXIF data, wrap the access in a [`with`] statement.
```go-html-template
{{ with $image.Exif }}
@@ -181,7 +181,7 @@ You may access Exif data in JPEG and TIFF images. To prevent errors when process
{{ end }}
```
You may also access Exif fields individually, using the [`lang.FormatNumber`] function to format the fields as needed.
You may also access EXIF fields individually, using the [`lang.FormatNumber`] function to format the fields as needed.
```go-html-template
{{ with $image.Exif }}
@@ -198,7 +198,7 @@ You may also access Exif fields individually, using the [`lang.FormatNumber`] fu
{{ end }}
```
#### Exif Variables
#### EXIF variables
.Date
: Image creation date/time. Format with the [time.Format] function.
@@ -210,9 +210,9 @@ You may also access Exif fields individually, using the [`lang.FormatNumber`] fu
: GPS longitude in degrees.
.Tags
: A collection of the available Exif tags for this image. You may include or exclude specific tags from this collection in the [site configuration](#exif-data).
: A collection of the available EXIF tags for this image. You may include or exclude specific tags from this collection in the [site configuration](#exif-data).
## Image Processing Options
## Image processing options
The [`Resize`], [`Fit`], [`Fill`], and [`Crop`] methods accept a space-separated, case-insensitive list of options. The order of the options within the list is irrelevant.
@@ -265,7 +265,7 @@ For example, if you have a 400x200 image with a bird in the upper left quadrant,
If you apply [rotation](#rotation) when using the [`Crop`] or [`Fill`] method, specify the anchor relative to the rotated image.
### Target Format
### Target format
By default, Hugo encodes the image in the source format. You may convert the image to another format by specifying `bmp`, `gif`, `jpeg`, `jpg`, `png`, `tif`, `tiff`, or `webp`.
@@ -313,7 +313,7 @@ The default value is `photo`. You may override the default value in the [site co
{{ $image.Resize "600x webp picture" }}
```
### Background Color
### Background color
When converting an image from a format that supports transparency (e.g., PNG) to a format that does _not_ support transparency (e.g., JPEG), you may specify the background color of the resulting image.
@@ -325,7 +325,7 @@ The default value is `#ffffff` (white). You may override the default value in th
{{ $image.Resize "600x jpg #b31280" }}
```
### Resampling Filter
### Resampling filter
You may specify the resampling filter used when resizing an image. Commonly used resampling filters include:
@@ -346,7 +346,7 @@ The default value is `Box`. You may override the default value in the [site conf
See [github.com/disintegration/imaging] for the complete list of resampling filters. If you wish to improve image quality at the expense of performance, you may wish to experiment with the alternative filters.
## Image Processing Examples
## Image processing examples
_The photo of the sunset used in the examples below is Copyright [Bjørn Erik Pedersen](https://commons.wikimedia.org/wiki/User:Bep) (Creative Commons Attribution-Share Alike 4.0 International license)_
@@ -378,9 +378,9 @@ Call the shortcode from your Markdown like this:
Note the self-closing shortcode syntax above. You may call the `imgproc` shortcode with or without **inner content**.
{{% /note %}}
## Imaging Configuration
## Imaging configuration
### Processing Options
### Processing options
Define an `imaging` section in your site configuration to set the default [image processing options](#image-processing-options).
@@ -408,9 +408,9 @@ quality
resampleFilter
: See image processing options: [resampling filter](#resampling-filter).
### Exif Data
### EXIF data
Define an `imaging.exif` section in your site configuration to control the availability of Exif data.
Define an `imaging.exif` section in your site configuration to control the availability of EXIF data.
{{< code-toggle file="hugo" copy=true >}}
[imaging.exif]
@@ -427,16 +427,16 @@ disableLatLong
: Hugo extracts the GPS latitude and longitude into `.Lat` and `.Long`. Set this to `true` to disable. Default is `false`.
excludeFields
: Regular expression matching the Exif tags to exclude from the `.Tags` collection. Default is&nbsp;`""`.
: Regular expression matching the EXIF tags to exclude from the `.Tags` collection. Default is&nbsp;`""`.
includeFields
: Regular expression matching the Exif tags to include in the `.Tags` collection. Default is&nbsp;`""`. To include all available tags, set this value to&nbsp;`".*"`.
: Regular expression matching the EXIF tags to include in the `.Tags` collection. Default is&nbsp;`""`. To include all available tags, set this value to&nbsp;`".*"`.
{{% note %}}
To improve performance and decrease cache size, if you set neither `excludeFields` nor `includeFields`, Hugo excludes the following tags: `ColorSpace`, `Contrast`, `Exif`, `Exposure[M|P|B]`, `Flash`, `GPS`, `JPEG`, `Metering`, `Resolution`, `Saturation`, `Sensing`, `Sharp`, and `WhiteBalance`.
{{% /note %}}
## Smart Cropping of Images
## Smart cropping of images
By default, Hugo uses the [Smartcrop] library when cropping images with the `Crop` or`Fill` methods. You can set the anchor point manually, but in most cases the `Smart` option will make a good choice.
@@ -446,7 +446,7 @@ Examples using the sunset image from above:
{{< imgproc sunset Crop "200x200 smart" />}}
## Image Processing Performance Consideration
## Image processing performance consideration
Hugo caches processed images in the `resources` directory. If you include this directory in source control, Hugo will not have to regenerate the images in a CI/CD workflow (e.g., GitHub Pages, GitLab Pages, Netlify, etc.). This results in faster builds.
@@ -458,7 +458,7 @@ hugo --gc
[time.Format]: /functions/dateformat
[`anchor`]: /content-management/image-processing#anchor
[mounted]: /hugo-modules/configuration#module-config-mounts
[mounted]: /hugo-modules/configuration#module-configuration-mounts
[page bundle]: /content-management/page-bundles
[`lang.FormatNumber`]: /functions/lang
[filters]: /functions/images
@@ -1,5 +1,5 @@
---
title: Multilingual Mode
title: Multilingual mode
linkTitle: Multilingual
description: Hugo supports the creation of websites with multiple languages side by side.
categories: [content management]
@@ -17,57 +17,79 @@ You should define the available languages in a `languages` section in your site
Also See [Hugo Multilingual Part 1: Content translation].
## Configure Languages
## Configure languages
The following is an example of a site configuration for a multilingual Hugo project:
This is an example of a site configuration for a multilingual project. Any key not defined in a `languages` object will fall back to the global value in the root of your site configuration.
{{< code-toggle file="hugo" >}}
defaultContentLanguage = "en"
copyright = "Everything is mine"
defaultContentLanguage = 'de'
defaultContentLanguageInSubdir = true
[params]
[params.navigation]
help = "Help"
[languages]
[languages.en]
title = "My blog"
[languages.de]
contentDir = 'content/de'
disabled = false
languageCode = 'de-DE'
languageDirection = 'ltr'
languageName = 'Deutsch'
title = 'Projekt Dokumentation'
weight = 1
[languages.de.params]
subtitle = 'Referenz, Tutorials und Erklärungen'
[languages.en]
contentDir = 'content/en'
disabled = false
languageCode = 'en-US'
languageDirection = 'ltr'
languageName = 'English'
title = 'Project Documentation'
weight = 2
[languages.en.params]
linkedin = "https://linkedin.com/whoever"
[languages.fr]
title = "Mon blogue"
weight = 2
[languages.fr.params]
linkedin = "https://linkedin.com/fr/whoever"
[languages.fr.params.navigation]
help = "Aide"
[languages.ar]
title = "مدونتي"
weight = 2
languagedirection = "rtl"
[languages.pt-pt]
title = "O meu blog"
weight = 3
subtitle = 'Reference, Tutorials, and Explanations'
{{< /code-toggle >}}
Anything not defined in a `languages` block will fall back to the global value for that key (e.g., `copyright` for the English `en` language). This also works for `params`, as demonstrated with `help` above: You will get the value `Aide` in French and `Help` in all the languages without this parameter set.
`defaultContentLanguage`
: (`string`) The project's default language tag as defined by [RFC 5646]. Must be lower case, and must match one of the defined language keys. Default is `en`. Examples:
With the configuration above, all content, sitemap, RSS feeds, pagination,
and taxonomy pages will be rendered below `/` in English (your default content language) and then below `/fr` in French.
- `en`
- `en-gb`
- `pt-br`
When working with front matter `Params` in [single page templates], omit the `params` in the key for the translation.
`defaultContentLanguageInSubdir`
: (`bool`) If `true`, Hugo renders the default language site in a subdirectory matching the `defaultContentLanguage`. Default is `false`.
`defaultContentLanguage` sets the project's default language. If not set, the default language will be `en`.
`contentDir`
: (`string`) The content directory for this language. Omit if [translating by file name].
If the default language needs to be rendered below its own language code (`/en`) like the others, set `defaultContentLanguageInSubdir: true`.
`disabled`
: (`bool`) If `true`, Hugo will not render content for this language. Default is `false`.
Only the obvious non-global options can be overridden per language. Examples of global options are `baseURL`, `buildDrafts`, etc.
`languageCode`
: (`string`) The language tag as defined by [RFC 5646]. This value may include upper and lower case characters, hyphens or underscores, and does not affect localization or URLs. Hugo uses this value to populate the `language` element in the [built-in RSS template], and the `lang` attribute of the `html` element in the [built-in alias template]. Examples:
**Please note:** use lowercase language codes, even when using regional languages (ie. use pt-pt instead of pt-PT). Currently Hugo language internals lowercase language codes, which can cause conflicts with settings like `defaultContentLanguage` which are not lowercased. Please track the evolution of this issue in [Hugo repository issue tracker](https://github.com/gohugoio/hugo/issues/7344)
- `en`
- `en-GB`
- `pt-BR`
`languageDirection`
: (`string`) The language direction, either left-to-right (`ltr`) or right-to-left (`rtl`). Use this value in your templates with the global [`dir`] HTML attribute.
`languageName`
: (`string`) The language name, typically used when rendering a language switcher.
`title`
: (`string`) The language title. When set, this overrides the site title for this language.
`weight`
: (`int`) The language weight. When set to a non-zero value, this is the primary sort criteria for this language.
[`dir`]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir
[built-in RSS template]: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml
[built-in alias template]: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/alias.html
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646
[translating by file name]: #translation-by-file-name
### Changes in Hugo 0.112.0
@@ -76,7 +98,7 @@ Only the obvious non-global options can be overridden per language. Examples of
In Hugo `v0.112.0` we consolidated all configuration options, and improved how the languages and their parameters are merged with the main configuration. But while testing this on Hugo sites out there, we received some error reports and reverted some of the changes in favor of deprecation warnings:
1. `site.Language.Params` is deprecated. Use `site.Params` directly.
1. Adding custom params to the top level language config is deprecated, add all of these below `[params]`, see `color` in the example below.
1. Adding custom parameters to the top level language configuration is deprecated, add all of these below `[params]`, see `color` in the example below.
```toml
title = "My blog"
@@ -92,35 +114,36 @@ color = "blue"
In the example above, all settings except `color` below `params` map to predefined configuration options in Hugo for the site and its language, and should be accessed via the documented accessors:
```
```go-html-template
{{ site.Title }}
{{ site.LanguageCode }}
{{ site.Params.color }}
```
### Disable a Language
### Disable a language
You can disable one or more languages. This can be useful when working on a new translation.
To disable a language within a `languages` object in your site configuration:
{{< code-toggle file="hugo" >}}
disableLanguages = ["fr", "ja"]
{{< code-toggle file="hugo" copy=false >}}
[languages.es]
disabled = true
{{< /code-toggle >}}
To disable one or more languages in the root of your site configuration:
{{< code-toggle file="hugo" copy=false >}}
disableLanguages = ["es", "fr"]
{{< /code-toggle >}}
To disable one or more languages using an environment variable:
```bash
HUGO_DISABLELANGUAGES="es fr" hugo
```
Note that you cannot disable the default content language.
We kept this as a standalone setting to make it easier to set via [OS environment]:
```bash
HUGO_DISABLELANGUAGES="fr ja" hugo
```
If you have already a list of disabled languages in `hugo.toml`, you can enable them in development like this:
```bash
HUGO_DISABLELANGUAGES=" " hugo server
```
### Configure Multilingual Multihost
### Configure multilingual multihost
From **Hugo 0.31** we support multiple languages in a multihost configuration. See [this issue](https://github.com/gohugoio/hugo/issues/4027) for details.
@@ -167,12 +190,11 @@ Press Ctrl+C to stop
Live reload and `--navigateToChanged` between the servers work as expected.
## Translate Your Content
## Translate your content
There are two ways to manage your content translations. Both ensure each page is assigned a language and is linked to its counterpart translations.
### Translation by filename
### Translation by file name
Considering the following example:
@@ -182,9 +204,9 @@ Considering the following example:
The first file is assigned the English language and is linked to the second.
The second file is assigned the French language and is linked to the first.
Their language is __assigned__ according to the language code added as a __suffix to the filename__.
Their language is __assigned__ according to the language code added as a __suffix to the file name__.
By having the same **path and base filename**, the content pieces are __linked__ together as translated pages.
By having the same **path and base file name**, the content pieces are __linked__ together as translated pages.
{{% note %}}
If a file has no language code, it will be assigned the default language.
@@ -192,7 +214,7 @@ If a file has no language code, it will be assigned the default language.
### Translation by content directory
This system uses different content directories for each of the languages. Each language's content directory is set using the `contentDir` param.
This system uses different content directories for each of the languages. Each language's content directory is set using the `contentDir` parameter.
{{< code-toggle file="hugo" >}}
languages:
@@ -234,11 +256,11 @@ Considering the following example:
translationKey: "about"
{{< /code-toggle >}}
By setting the `translationKey` front matter param to `about` in all three pages, they will be __linked__ as translated pages.
By setting the `translationKey` front matter parameter to `about` in all three pages, they will be __linked__ as translated pages.
### Localizing permalinks
Because paths and filenames are used to handle linking, all translated pages will share the same URL (apart from the language subdirectory).
Because paths and file names are used to handle linking, all translated pages will share the same URL (apart from the language subdirectory).
To localize URLs:
@@ -257,7 +279,7 @@ slug: "a-propos"
At render, Hugo will build both `/about/` and `/fr/a-propos/` without affecting the translation link.
### Page Bundles
### Page bundles
To avoid the burden of having to duplicate files, each Page Bundle inherits the resources of its linked translated pages' bundles except for the content files (Markdown files, HTML files etc...).
@@ -269,10 +291,10 @@ If, across the linked bundles, two or more files share the same basename, only o
* First file found across bundles by order of language `Weight`.
{{% note %}}
Page Bundle resources follow the same language assignment logic as content files, both by filename (`image.jpg`, `image.fr.jpg`) and by directory (`english/about/header.jpg`, `french/about/header.jpg`).
Page Bundle resources follow the same language assignment logic as content files, both by file name (`image.jpg`, `image.fr.jpg`) and by directory (`english/about/header.jpg`, `french/about/header.jpg`).
{{%/ note %}}
## Reference the Translated Content
## Reference translated content
To create a list of links to translated content, use a template similar to the following:
@@ -293,7 +315,7 @@ The above can be put in a `partial` (i.e., inside `layouts/partials/`) and inclu
The above also uses the [`i18n` function][i18func] described in the next section.
### List All Available Languages
### List all available languages
`.AllTranslations` on a `Page` can be used to list all translations, including the page itself. On the home page it can be used to build a language navigator:
@@ -305,7 +327,7 @@ The above also uses the [`i18n` function][i18func] described in the next section
</ul>
{{< /code >}}
## Translation of Strings
## Translation of strings
Hugo uses [go-i18n] to support string translations. [See the project's source repository][go-i18n-source] to find tools that will help you manage your translation workflows.
@@ -484,7 +506,7 @@ See [lang.FormatNumber] and [lang.FormatNumberCustom] for details.
With this template code:
```go-html-template
{{ 512.5032 | lang.FormatPercent 2 }} ---> 512.50%
{{ 512.5032 | lang.FormatPercent 2 }} 512.50%
```
The rendered page displays:
@@ -585,7 +607,7 @@ weight = 20
For a simple menu with two languages, these menu entries are easy to create and maintain. For a larger menu, or with more than two languages, using translation tables as described above is preferable.
## Missing Translations
## Missing translations
If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown.
@@ -604,7 +626,7 @@ hugo --printI18nWarnings | grep i18n
i18n|MISSING_TRANSLATION|en|wordCount
```
## Multilingual Themes support
## Multilingual themes support
To support Multilingual mode in your themes, some considerations must be taken for the URLs in the templates. If there is more than one language, URLs must meet the following criteria:
@@ -1,8 +1,8 @@
---
title: Content Organization
title: Content organization
linkTitle: Organization
description: Hugo assumes that the same structure that works to organize your source content is used to organize the rendered site.
categories: [content management,fundamentals]
categories: [fundamentals,content management]
keywords: [sections,content,organization,bundle,resources]
menu:
docs:
@@ -13,7 +13,7 @@ weight: 20
aliases: [/content/sections/]
---
## Page Bundles
## Page bundles
Hugo `0.32` announced page-relative images and other resources packaged into `Page Bundles`.
@@ -29,7 +29,7 @@ The bundle documentation is a **work in progress**. We will publish more compreh
{{% /note %}}
## Organization of Content Source
## Organization of content source
In Hugo, your content should be organized in a manner that reflects the rendered website.
@@ -52,12 +52,12 @@ Without any additional configuration, the following will automatically work:
└── second.md // <- https://example.com/quote/second/
```
## Path Breakdown in Hugo
## Path breakdown in Hugo
The following demonstrates the relationships between your content organization and the output URL structure for your Hugo website when it renders. These examples assume you are [using pretty URLs][pretty], which is the default behavior for Hugo. The examples also assume a key-value of `baseURL = "https://example.com"` in your [site's configuration file][config].
### Index Pages: `_index.md`
### Index pages: `_index.md`
`_index.md` has a special role in Hugo. It allows you to add front matter and content to your [list templates][lists]. These templates include those for [section templates], [taxonomy templates], [taxonomy terms templates], and your [homepage template].
@@ -94,7 +94,7 @@ https://example.com/posts/index.html
The [sections] can be nested as deeply as you want. The important thing to understand is that to make the section tree fully navigational, at least the lower-most section must include a content file. (i.e. `_index.md`).
### Single Pages in Sections
### Single pages in sections
Single content files in each of your sections will be rendered as [single page templates][singles]. Here is an example of a single `post` within `posts`:
@@ -121,7 +121,7 @@ https://example.com/posts/my-first-hugo-post/index.html
```
## Paths Explained
## Paths explained
The following concepts provide more insight into the relationship between your project's organization and the default Hugo behavior when building output for the website.
@@ -1,5 +1,5 @@
---
title: Page Bundles
title: Page bundles
description: Content organization using Page Bundles
keywords: [page, bundle, leaf, branch]
categories: [content management]
@@ -19,23 +19,22 @@ A Page Bundle can be one of:
- Branch Bundle (home page, section, taxonomy terms, taxonomy list)
| | Leaf Bundle | Branch Bundle |
|-------------------------------------|----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|-------------------------------------|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Usage | Collection of content and attachments for single pages | Collection of attachments for section pages (home page, section, taxonomy terms, taxonomy list) |
| Index filename | `index.md` [^fn:1] | `_index.md` [^fn:1] |
| Index file name | `index.md` [^fn:1] | `_index.md` [^fn:1] |
| Allowed Resources | Page and non-page (like images, PDF, etc.) types | Only non-page (like images, PDF, etc.) types |
| Where can the Resources live? | At any directory level within the leaf bundle directory. | Only in the directory level **of** the branch bundle directory i.e. the directory containing the `_index.md` ([ref](https://discourse.gohugo.io/t/question-about-content-folder-structure/11822/4?u=kaushalmodi)). |
| Layout type | `single` | `list` |
| Layout type | [`single`](/templates/single-page-templates/) | [`list`](/templates/lists) |
| Nesting | Does not allow nesting of more bundles under it | Allows nesting of leaf or branch bundles under it |
| Example | `content/posts/my-post/index.md` | `content/posts/_index.md` |
| Content from non-index page files... | Accessed only as page resources | Accessed only as regular pages |
| Content from non-index page files...| Accessed only as page resources | Accessed only as regular pages |
## Leaf Bundles {#leaf-bundles}
## Leaf bundles
A _Leaf Bundle_ is a directory at any hierarchy within the `content/`
directory, that contains an **`index.md`** file.
### Examples of Leaf Bundle organization {#examples-of-leaf-bundle-organization}
### Examples of leaf bundle organization {#examples-of-leaf-bundle-organization}
```text
content/
@@ -92,7 +91,7 @@ as long as it is not inside another **leaf** bundle.
{{% /note %}}
### Headless Bundle {#headless-bundle}
### Headless bundle
A headless bundle is a bundle that is configured to not get published
anywhere:
@@ -126,7 +125,7 @@ Explanation of the above example:
---
A leaf bundle can be made headless by adding below in the Front Matter
A leaf bundle can be made headless by adding below in the front matter
(in the `index.md`):
{{< code-toggle file="content/headless/index.md" fm=true copy=false >}}
@@ -138,7 +137,7 @@ There are many use cases of such headless page bundles:
- Shared media galleries
- Reusable page content "snippets"
## Branch Bundles {#branch-bundles}
## Branch bundles
A _Branch Bundle_ is any directory at any hierarchy within the
`content/` directory, that contains at least an **`_index.md`** file.
@@ -151,7 +150,7 @@ type as a content resource as long as it is a content type recognized by Hugo.
{{% /note %}}
### Examples of Branch Bundle organization {#examples-of-branch-bundle-organization}
### Examples of branch bundle organization
```text
content/
@@ -1,5 +1,5 @@
---
title: Page Resources
title: Page resources
description: Page resources -- images, other pages, documents, etc. -- have page-relative URLs and their own metadata.
categories: [content management]
keywords: [bundle,content,resources]
@@ -42,7 +42,7 @@ ResourceType
: The main type of the resource's [Media Type](/templates/output-formats/#media-types). For example, a file of MIME type `image/jpeg` has the ResourceType `image`. A `Page` will have `ResourceType` with value `page`.
Name
: Default value is the filename (relative to the owning page). Can be set in front matter.
: Default value is the file name (relative to the owning page). Can be set in front matter.
Title
: Default value is the same as `.Name`. Can be set in front matter.
@@ -67,21 +67,21 @@ with the contents of the file. Use this to create inline resources.
{{ end }}
{{ with .Resources.GetMatch "img.png" }}
<img src="data:{{ .MediaType }};base64,{{ .Content | base64Encode }}">
<img src="data:{{ .MediaType.Type }};base64,{{ .Content | base64Encode }}">
{{ end }}
```
MediaType
: The MIME type of the resource, such as `image/jpeg`.
MediaType.Type
: The media type (formerly known as a MIME type) of the resource (e.g., `image/jpeg`).
MediaType.MainType
: The main type of the resource's MIME type. For example, a file of MIME type `application/pdf` has for MainType `application`.
: The main type of the resource's media type (e.g., `image`).
MediaType.SubType
: The subtype of the resource's MIME type. For example, a file of MIME type `application/pdf` has for SubType `pdf`. Note that this is not the same as the file extension. For example, Microsoft PowerPoint files (`.ppt`) have a subtype of `vnd.ms-powerpoint`.
: The subtype of the resource's type (e.g., `jpeg`). This may or may not correspond to the file suffix.
MediaType.Suffixes
: A slice of possible suffixes for the resource's MIME type.
: A slice of possible file suffixes for the resource's media type (e.g., `[jpg jpeg jpe jif jfif]`).
## Methods
@@ -101,7 +101,7 @@ Match
GetMatch
: Same as `Match` but will return the first match.
### Pattern Matching
### Pattern matching
```go
// Using Match/GetMatch to find this images/sunset.jpg ?
@@ -115,7 +115,7 @@ GetMatch
```
## Page Resources Metadata
## Page resources metadata
The page resources' metadata is managed from the corresponding page's front matter with an array/table parameter named `resources`. You can batch assign values using [wildcards](https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm).
+10 -10
View File
@@ -1,5 +1,5 @@
---
title: Related Content
title: Related content
description: List related content in "See Also" sections.
categories: [content management]
keywords: [content]
@@ -12,9 +12,9 @@ weight: 110
aliases: [/content/related/,/related/]
---
Hugo uses a set of factors to identify a page's related content based on Front Matter parameters. This can be tuned to the desired set of indices and parameters or left to Hugo's default [Related Content configuration](#configure-related-content).
Hugo uses a set of factors to identify a page's related content based on front matter parameters. This can be tuned to the desired set of indices and parameters or left to Hugo's default [Related Content configuration](#configure-related-content).
## List Related Content
## List related content
To list up to 5 related pages (which share the same _date_ or _keyword_ parameters) is as simple as including something similar to this partial in your single page template:
@@ -60,7 +60,7 @@ A fictional example using all of the above options:
We improved and simplified this feature in Hugo 0.111.0. Before this we had 3 different methods: `Related`, `RelatedTo` and `RelatedIndicies`. Now we have only one method: `Related`. The old methods are still available but deprecated. Also see [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-relashionships-with-related-content/) for a great explanation of more advanced usage of this feature.
{{% /note %}}
## Index Content Headings in Related Content
## Index content headings in related content
{{< new-in "0.111.0" >}}
@@ -105,7 +105,7 @@ weight = 80
{{ end }}
```
## Configure Related Content
## Configure related content
Hugo provides a sensible default configuration of Related Content, but you can fine-tune this in your configuration, on the global or language level if needed.
@@ -130,10 +130,10 @@ Note that if you have configured `tags` as a taxonomy, `tags` will also be added
Custom configuration should be set using the same syntax.
{{% note %}}
If you add a `related` config section, you need to add a complete configuration. It is not possible to just set, say, `includeNewer` and use the rest from the Hugo defaults.
If you add a `related` configuration section, you need to add a complete configuration. It is not possible to just set, say, `includeNewer` and use the rest from the Hugo defaults.
{{% /note %}}
### Top Level Config Options
### Top level configuration options
threshold
: A value between 0-100. Lower value will give more, but maybe not so relevant, matches.
@@ -144,10 +144,10 @@ includeNewer
toLower
: Set to true to lower case keywords in both the indexes and the queries. This may give more accurate results at a slight performance penalty. Note that this can also be set per index.
### Config Options per Index
### Configuration options per index
name
: The index name. This value maps directly to a page param. Hugo supports string values (`author` in the example) and lists (`tags`, `keywords` etc.) and time and date objects.
: The index name. This value maps directly to a page parameter. Hugo supports string values (`author` in the example) and lists (`tags`, `keywords` etc.) and time and date objects.
type
: {{< new-in "0.111.0" >}}. One of `basic`(default) or `fragments`.
@@ -168,7 +168,7 @@ pattern
toLower
: See above.
## Performance Considerations
## Performance considerations
**Fast is Hugo's middle name** and we would not have released this feature had it not been blistering fast.
@@ -1,6 +1,5 @@
---
title: Content Sections
linkTitle: Sections
title: Sections
description: Hugo generates a **section tree** that matches your content.
categories: [content management]
keywords: [lists,sections,content types,organization]
@@ -31,7 +30,7 @@ A **section** cannot be defined or overridden by a front matter parameter -- it
is strictly derived from the content organization structure.
{{% /note %}}
## Nested Sections
## Nested sections
The sections can be nested as deeply as you need.
@@ -55,7 +54,7 @@ currently always the *root section* only (`/blog/funny-cats/mypost/ => blog`).
If you need a specific template for a sub-section, you need to adjust either the `type` or `layout` in front matter.
{{% /note %}}
## Example: Breadcrumb Navigation
## Example: breadcrumb navigation
With the available [section variables and methods](#section-page-variables-and-methods) you can build powerful navigation. One common example would be a partial to show Breadcrumb navigation:
@@ -74,17 +73,17 @@ With the available [section variables and methods](#section-page-variables-and-m
</nav>
{{< /code >}}
## Section Page Variables and Methods
## Section page variables and methods
Also see [Page Variables](/variables/page/).
{{< readfile file="/content/en/readfiles/sectionvars.md" markdown="true" >}}
## Content Section Lists
## Content section lists
Hugo will automatically create a page for each *root section* that lists all the content in that section. See the documentation on [section templates] for details on customizing the way these pages are rendered.
## Content *Section* vs Content *Type*
## Content *section* vs. content *type*
By default, everything created within a section will use the [content `type`][content type] that matches the *root section* name. For example, Hugo will assume that `posts/post-1.md` has a `posts` content `type`. If you are using an [archetype] for your `posts` section, Hugo will generate front matter according to what it finds in `archetypes/posts.md`.
@@ -13,7 +13,7 @@ aliases: [/extras/shortcodes/]
testparam: "Hugo Rocks!"
---
## What a Shortcode is
## What a shortcode is
Hugo loves Markdown because of its simple content format, but there are times when Markdown falls short. Often, content authors are forced to add raw HTML (e.g., video `<iframe>`'s) to Markdown content. We think this contradicts the beautiful simplicity of Markdown's syntax.
@@ -23,7 +23,7 @@ A shortcode is a simple snippet inside a content file that Hugo will render usin
In addition to cleaner Markdown, shortcodes can be updated any time to reflect new classes, techniques, or standards. At the point of site generation, Hugo shortcodes will easily merge in your changes. You avoid a possibly complicated search and replace operation.
## Use Shortcodes
## Use shortcodes
{{< youtube 2xkNJL4gJ9E >}}
@@ -54,7 +54,7 @@ You can pass multiple lines as parameters to a shortcode by using raw string lit
and a new line with a "quoted string".` */>}}
```
### Shortcodes with Markdown
### Shortcodes with markdown
In Hugo `0.55` we changed how the `%` delimiter works. Shortcodes using the `%` as the outer-most delimiter will now be fully rendered when sent to the content renderer. They can be part of the generated table of contents, footnotes, etc.
@@ -64,7 +64,7 @@ If you want the old behavior, you can put the following line in the start of you
{{ $_hugo_config := `{ "version": 1 }` }}
```
### Shortcodes Without Markdown
### Shortcodes without markdown
The `<` character indicates that the shortcode's inner content does *not* need further rendering. Often shortcodes without Markdown include internal HTML:
@@ -72,11 +72,11 @@ The `<` character indicates that the shortcode's inner content does *not* need f
{{</* myshortcode */>}}<p>Hello <strong>World!</strong></p>{{</* /myshortcode */>}}
```
### Nested Shortcodes
### Nested shortcodes
You can call shortcodes within other shortcodes by creating your own templates that leverage the `.Parent` variable. `.Parent` allows you to check the context in which the shortcode is being called. See [Shortcode templates][sctemps].
## Use Hugo's Built-in Shortcodes
## Use Hugo's built-in shortcodes
Hugo ships with a set of predefined shortcodes that represent very common usage. These shortcodes are provided for author convenience and to keep your Markdown content clean.
@@ -125,13 +125,13 @@ attr
attrlink
: If the attribution text needs to be hyperlinked, URL of the destination.
#### Example `figure` Input
#### Example `figure` input
{{< code file="figure-input-example.md" >}}
{{</* figure src="elephant.jpg" title=">An elephant at sunset" */>}}
{{</* figure src="elephant.jpg" title="An elephant at sunset" */>}}
{{< /code >}}
#### Example `figure` Output
#### Example `figure` output
```html
<figure>
@@ -254,17 +254,17 @@ Include this in your markdown:
### `param`
Gets a value from the current `Page's` params set in front matter, with a fallback to the site param value. It will log an `ERROR` if the param with the given key could not be found in either.
Gets a value from the current `Page's` parameters set in front matter, with a fallback to the site parameter value. It will log an `ERROR` if the parameter with the given key could not be found in either.
```bash
{{</* param testparam */>}}
```
Since `testparam` is a param defined in front matter of this page with the value `Hugo Rocks!`, the above will print:
Since `testparam` is a parameter defined in front matter of this page with the value `Hugo Rocks!`, the above will print:
{{< param testparam >}}
To access deeply nested params, use "dot syntax", e.g:
To access deeply nested parameters, use "dot syntax", e.g:
```bash
{{</* param "my.nested.param" */>}}
@@ -282,14 +282,14 @@ Read a more extensive description of `ref` and `relref` in the [cross references
`ref` and `relref` take exactly one required parameter of _reference_, quoted and in position `0`.
#### Example `ref` and `relref` Input
#### Example `ref` and `relref` input
```go-html-template
[Neat]({{</* ref "blog/neat.md" */>}})
[Who]({{</* relref "about.md#who" */>}})
```
#### Example `ref` and `relref` Output
#### Example `ref` and `relref` output
Assuming that standard Hugo pretty URLs are turned on.
@@ -350,7 +350,7 @@ The `youtube` shortcode embeds a responsive video player for [YouTube videos]. O
https://www.youtube.com/watch?v=w7Ft2ymGmfc
```
#### Example `youtube` Input
#### Example `youtube` input
Copy the YouTube video ID that follows `v=` in the video's URL and pass it to the `youtube` shortcode:
@@ -371,7 +371,7 @@ For [accessibility reasons](https://dequeuniversity.com/tips/provide-iframe-titl
{{</* youtube id="w7Ft2ymGmfc" title="A New Hugo Site in Under Two Minutes" */>}}
{{< /code >}}
#### Example `youtube` Output
#### Example `youtube` output
Using the preceding `youtube` example, the following HTML will be added to your rendered website's markup:
@@ -379,17 +379,17 @@ Using the preceding `youtube` example, the following HTML will be added to your
{{< youtube id="w7Ft2ymGmfc" autoplay="true" >}}
{{< /code >}}
#### Example `youtube` Display
#### Example `youtube` display
Using the preceding `youtube` example (without `autoplay="true"`), the following simulates the displayed experience for visitors to your website. Naturally, the final display will be contingent on your style sheets and surrounding markup. The video is also include in the [Quick Start of the Hugo documentation][quickstart].
{{< youtube w7Ft2ymGmfc >}}
## Privacy Config
## Privacy configuration
To learn how to configure your Hugo site to meet the new EU privacy regulation, see [Hugo and the GDPR].
## Create Custom Shortcodes
## Create custom shortcodes
To learn more about creating custom shortcodes, see the [shortcode template documentation].
@@ -1,6 +1,5 @@
---
title: Static Files
linkTitle: Static Files
title: Static files
description: Files that get served **statically** (as-is, no modification) on the site root.
categories: [content management]
keywords: [source, directories]
@@ -18,7 +17,7 @@ all **static files** (e.g. stylesheets, JavaScript, images). The static files ar
Hugo can be configured to look into a different directory, or even
**multiple directories** for such static files by configuring the
`staticDir` parameter in the [site config]. All the files in all the
`staticDir` parameter in the [site configuration]. All the files in all the
static directories will form a union filesystem.
This union filesystem will be served from your site root. So a file
@@ -65,5 +64,5 @@ Note 2
: The example above is a [multihost setup]. In a regular setup, all
the static directories will be available to all sites.
[site config]: /getting-started/configuration/#all-configuration-settings
[site configuration]: /getting-started/configuration/#all-configuration-settings
[multihost setup]: /content-management/multilingual/#configure-multilingual-multihost
+16 -16
View File
@@ -1,5 +1,5 @@
---
title: Content Summaries
title: Content summaries
linkTitle: Summaries
description: Hugo generates summaries of your content.
categories: [content management]
@@ -15,7 +15,7 @@ aliases: [/content/summaries/,/content-management/content-summaries/]
With the use of the `.Summary` [page variable][pagevariables], Hugo generates summaries of content to use as a short version in summary views.
## Summary Splitting Options
## Summary splitting options
* Automatic Summary Split
* Manual Summary Split
@@ -23,7 +23,7 @@ With the use of the `.Summary` [page variable][pagevariables], Hugo generates su
It is natural to accompany the summary with links to the original content, and a common design pattern is to see this link in the form of a "Read More ..." button. See the `.RelPermalink`, `.Permalink`, and `.Truncated` [page variables][pagevariables].
### Automatic Summary Splitting
### Automatic summary splitting
By default, Hugo automatically takes the first 70 words of your content as its summary and stores it into the `.Summary` page variable for use in your templates. You may customize the summary length by setting `summaryLength` in your [site configuration](/getting-started/configuration/).
@@ -35,7 +35,7 @@ You can customize how HTML tags in the summary are loaded using functions such a
The Hugo-defined summaries are set to use word count calculated by splitting the text by one or more consecutive whitespace characters. If you are creating content in a `CJK` language and want to use Hugo's automatic summary splitting, set `hasCJKLanguage` to `true` in your [site configuration](/getting-started/configuration/).
{{% /note %}}
### Manual Summary Splitting
### Manual summary splitting
Alternatively, you may add the <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> summary divider where you want to split the article.
@@ -57,7 +57,7 @@ Cons
Be careful to enter <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> exactly; i.e., all lowercase and with no whitespace.
{{% /note %}}
### Front Matter Summary
### Front matter summary
You might want your summary to be something other than the text that starts the article. In this case you can provide a separate summary in the `summary` variable of the article front matter.
@@ -67,7 +67,7 @@ Pros
Cons
: Extra work for content authors as they need to write an entirely separate piece of text as the summary of the article.
## Summary Selection Order
## Summary selection order
Because there are multiple ways in which a summary can be specified it is useful to understand the order of selection Hugo follows when deciding on the text to be returned by `.Summary`. It is as follows:
@@ -79,25 +79,25 @@ Because there are multiple ways in which a summary can be specified it is useful
Hugo uses the _first_ of the above steps that returns text. So if, for example, your article has both `summary` variable in its front matter and a <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> summary divider Hugo will use the manual summary split method.
{{% /note %}}
## Example: First 10 Articles with Summaries
## Example: first 10 articles with summaries
You can show content summaries with the following code. You could use the following snippet, for example, in a [section template].
{{< code file="page-list-with-summaries.html" >}}
{{ range first 10 .Pages }}
<article>
<!-- this <div> includes the title summary -->
<div>
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ .Summary }}
</div>
{{ if .Truncated }}
<article>
<!-- this <div> includes the title summary -->
<div>
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ .Summary }}
</div>
{{ if .Truncated }}
<!-- This <div> includes a read more link, but only if the summary is truncated... -->
<div>
<a href="{{ .RelPermalink }}">Read More…</a>
</div>
{{ end }}
</article>
{{ end }}
</article>
{{ end }}
{{< /code >}}
@@ -1,5 +1,5 @@
---
title: Syntax Highlighting
title: Syntax highlighting
description: Hugo comes with really fast syntax highlighting from Chroma.
keywords: [highlighting,chroma,code blocks,syntax]
categories: [content management]
@@ -14,13 +14,13 @@ aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/]
Hugo uses [Chroma](https://github.com/alecthomas/chroma) as its code highlighter; it is built in Go and is really, really fast.
## Configure Syntax Highlighter
## Configure syntax highlighter
See [Configure Highlight](/getting-started/configuration-markup#highlight).
## Generate Syntax Highlighter CSS
## Generate syntax highlighter CSS
If you run with `markup.highlight.noClasses=false` in your site config, you need a style sheet.
If you run with `markup.highlight.noClasses=false` in your site configuration, you need a style sheet.
You can generate one with Hugo:
@@ -30,20 +30,20 @@ hugo gen chromastyles --style=monokai > syntax.css
Run `hugo gen chromastyles -h` for more options. See https://xyproto.github.io/splash/docs/ for a gallery of available styles.
## Highlight Shortcode
## Highlight shortcode
Highlighting is carried out via the built-in [`highlight` shortcode](https://gohugo.io/content-management/shortcodes/#highlight). It takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode.
Highlighting is carried out via the built-in [`highlight` shortcode](/content-management/shortcodes/#highlight). It takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode.
Options:
* `linenos`: configure line numbers. Valid values are `true`, `false`, `table`, or `inline`. `false` will turn off line numbers if it's configured to be on in site config. `table` will give copy-and-paste friendly code blocks.
* `linenos`: configure line numbers. Valid values are `true`, `false`, `table`, or `inline`. `false` will turn off line numbers if it's configured to be on in site configuration. `table` will give copy-and-paste friendly code blocks.
* `hl_lines`: lists a set of line numbers or line number ranges to be highlighted.
* `linenostart=199`: starts the line number count from 199.
* `anchorlinenos`: Configure anchors on line numbers. Valid values are `true` or `false`;
* `lineanchors`: Configure a prefix for the anchors on line numbers. Will be suffixed with `-`, so linking to the line number 1 with the option `lineanchors=prefix` adds the anchor `prefix-1` to the page.
* `hl_inline` Highlight inside a `<code>` (inline HTML element) tag. Valid values are `true` or `false`. The `code` tag will get a class with name `code-inline`. {{< new-in "0.101.0" >}}
### Example: Highlight Shortcode
### Example: highlight shortcode
```go-html-template
{{</* highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" */>}}
@@ -76,9 +76,9 @@ func GetTitleFunc(style string) func(s string) string {
}
{{< / highlight >}}
## Highlight Hugo/GO Template Code
## Highlight Hugo/Go template code
For highlighting Hugo/GO template code on your page, add `/*` after the opening double curly braces and `*/` before closing curly braces.
For highlighting Hugo/Go template code on your page, add `/*` after the opening double curly braces and `*/` before closing curly braces.
``` go
{{</*/* myshortcode */*/>}}
@@ -90,11 +90,11 @@ Gives this:
{{</* myshortcode */>}}
```
## Highlight Template Func
## Highlight template function
See [Highlight](/functions/highlight/).
## Highlighting in Code Fences
## Highlighting in code fences
Highlighting in code fences is enabled by default.
@@ -132,7 +132,7 @@ func GetTitleFunc(style string) func(s string) string {
The options are the same as in the [highlighting shortcode](/content-management/syntax-highlighting/#highlight-shortcode), including `linenos=false`, but note the slightly different Markdown attribute syntax.
## List of Chroma Highlighting Languages
## List of Chroma highlighting languages
The full list of Chroma lexers and their aliases (which is the identifier used in the `highlight` template func or when doing highlighting in code fences):
@@ -12,7 +12,7 @@ weight: 150
aliases: [/taxonomies/overview/,/taxonomies/usage/,/indexes/overview/,/doc/indexes/,/extras/indexes]
---
## What is a Taxonomy?
## What is a taxonomy?
Hugo includes support for user-defined groupings of content called **taxonomies**. Taxonomies are classifications of logical relationships between content.
@@ -28,7 +28,7 @@ Value
: a piece of content assigned to a term
## Example Taxonomy: Movie Website
## Example taxonomy: movie website
Let's assume you are making a website about movies. You may want to include the following taxonomies:
@@ -41,7 +41,7 @@ Let's assume you are making a website about movies. You may want to include the
Then, in each of the movies, you would specify terms for each of these taxonomies (i.e., in the [front matter] of each of your movie content files). From these terms, Hugo would automatically create pages for each Actor, Director, Studio, Genre, Year, and Award, with each listing all of the Movies that matched that specific Actor, Director, Studio, Genre, Year, and Award.
### Movie Taxonomy Organization
### Movie taxonomy organization
To continue with the example of a movie site, the following demonstrates content relationships from the perspective of the taxonomy:
@@ -76,11 +76,11 @@ Moonrise Kingdom <- Value
...
```
## Hugo Taxonomy Defaults {#default-taxonomies}
## Default taxonomies
Hugo natively supports taxonomies.
Without adding a single line to your [site config][config] file, Hugo will automatically create taxonomies for `tags` and `categories`. That would be the same as manually [configuring your taxonomies](#configure-taxonomies) as below:
Without adding a single line to your [site configuration] file, Hugo will automatically create taxonomies for `tags` and `categories`. That would be the same as manually [configuring your taxonomies](#configure-taxonomies) as below:
{{< code-toggle file="hugo" copy=false >}}
[taxonomies]
@@ -88,7 +88,7 @@ Without adding a single line to your [site config][config] file, Hugo will autom
category = "categories"
{{</ code-toggle >}}
If you do not want Hugo to create any taxonomies, set `disableKinds` in your [site config][config] to the following:
If you do not want Hugo to create any taxonomies, set `disableKinds` in your [site configuration] to the following:
{{< code-toggle file="hugo" copy=false >}}
disableKinds = ["taxonomy","term"]
@@ -96,18 +96,18 @@ disableKinds = ["taxonomy","term"]
{{% page-kinds %}}
### Default Destinations
### Default destinations
When taxonomies are used---and [taxonomy templates] are provided---Hugo will automatically create both a page listing all the taxonomy's terms and individual pages with lists of content associated with each term. For example, a `categories` taxonomy declared in your configuration and used in your content front matter will create the following pages:
* A single page at `example.com/categories/` that lists all the [terms within the taxonomy]
* [Individual taxonomy list pages][taxonomy templates] (e.g., `/categories/development/`) for each of the terms that shows a listing of all pages marked as part of that taxonomy within any content file's [front matter]
## Configure Taxonomies
## Configure taxonomies
Custom taxonomies other than the [defaults](#default-taxonomies) must be defined in your [site config][config] before they can be used throughout the site. You need to provide both the plural and singular labels for each taxonomy. For example, `singular key = "plural value"` for TOML and `singular key: "plural value"` for YAML.
Custom taxonomies other than the [defaults](#default-taxonomies) must be defined in your [site configuration] before they can be used throughout the site. You need to provide both the plural and singular labels for each taxonomy. For example, `singular key = "plural value"` for TOML and `singular key: "plural value"` for YAML.
### Example: Adding a custom taxonomy named "series"
### Example: adding a custom taxonomy named "series"
{{% note %}}
While adding custom taxonomies, you need to put in the default taxonomies too, _if you want to keep them_.
@@ -120,9 +120,9 @@ While adding custom taxonomies, you need to put in the default taxonomies too, _
series = "series"
{{</ code-toggle >}}
### Example: Removing default taxonomies
### Example: removing default taxonomies
If you want to have just the default `tags` taxonomy, and remove the `categories` taxonomy for your site, you can do so by modifying the `taxonomies` value in your [site config][config].
If you want to have just the default `tags` taxonomy, and remove the `categories` taxonomy for your site, you can do so by modifying the `taxonomies` value in your [site configuration].
{{< code-toggle file="hugo" copy=false >}}
[taxonomies]
@@ -143,7 +143,7 @@ The configuration option `preserveTaxonomyNames` was removed in Hugo 0.55.
You can now use `.Page.Title` on the relevant taxonomy node to get the original value.
{{% /note %}}
## Add Taxonomies to Content
## Add taxonomies to content
Once a taxonomy is defined at the site level, any piece of content can be assigned to it, regardless of [content type] or [content section].
@@ -153,7 +153,7 @@ Assigning content to a taxonomy is done in the [front matter]. Simply create a v
If you would like the ability to quickly generate content files with preconfigured taxonomies or terms, read the docs on [Hugo archetypes](/content-management/archetypes/).
{{% /note %}}
### Example: Front Matter with Taxonomies
### Example: front matter with taxonomies
{{< code-toggle file="content/example.md" fm=true copy=false >}}
title = "Hugo: A fast and flexible static site generator"
@@ -164,13 +164,13 @@ slug = "hugo"
project_url = "https://github.com/gohugoio/hugo"
{{</ code-toggle >}}
## Order Taxonomies
## Order taxonomies
A content file can assign weight for each of its associate taxonomies. Taxonomic weight can be used for sorting or ordering content in [taxonomy list templates] and is declared in a content file's [front matter]. The convention for declaring taxonomic weight is `taxonomyname_weight`.
The following show a piece of content that has a weight of 22, which can be used for ordering purposes when rendering the pages assigned to the "a", "b" and "c" values of the `tags` taxonomy. It has also been assigned the weight of 44 when rendering the "d" category page.
### Example: Taxonomic `weight`
### Example: taxonomic `weight`
{{< code-toggle copy=false >}}
title = "foo"
@@ -186,7 +186,7 @@ By using taxonomic weight, the same piece of content can appear in different pos
Currently taxonomies only support the [default `weight => date` ordering of list content](/templates/lists/#default-weight--date--linktitle--filepath). For more information, see the documentation on [taxonomy templates](/templates/taxonomy-templates/).
{{% /note %}}
## Add custom metadata to a Taxonomy or Term
## Add custom metadata to a taxonomy or term
If you need to add custom metadata to your taxonomy terms, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in its front matter. Continuing with our 'Actors' example, let's say you want to add a Wikipedia page link to each actor. Your terms pages would be something like this:
@@ -203,4 +203,4 @@ wikipedia: "https://en.wikipedia.org/wiki/Bruce_Willis"
[taxonomy list templates]: /templates/taxonomy-templates/#taxonomy-list-templates
[taxonomy templates]: /templates/taxonomy-templates/
[terms within the taxonomy]: /templates/taxonomy-templates/#taxonomy-terms-templates "See how to order terms associated with a taxonomy"
[config]: /getting-started/configuration/
[configuration]: /getting-started/configuration/
+10 -10
View File
@@ -1,5 +1,5 @@
---
title: Table of Contents
title: Table of contents
description: Hugo can automatically parse Markdown content and create a Table of Contents you can use in your templates.
categories: [content management]
keywords: [table of contents, toc]
@@ -44,27 +44,27 @@ Hugo will take this Markdown and create a table of contents from `## Introductio
The built-in `.TableOfContents` variables outputs a `<nav id="TableOfContents">` element with a child `<ul>`, whose child `<li>` elements begin with appropriate HTML headings. See [the available settings](/getting-started/configuration-markup/#table-of-contents) to configure what heading levels you want to include in TOC.
## Template Example: Basic TOC
## Template example: basic TOC
The following is an example of a very basic [single page template]:
{{< code file="layout/_default/single.html" >}}
{{ define "main" }}
<main>
<main>
<article>
<header>
<header>
<h1>{{ .Title }}</h1>
</header>
{{ .Content }}
</header>
{{ .Content }}
</article>
<aside>
{{ .TableOfContents }}
{{ .TableOfContents }}
</aside>
</main>
</main>
{{ end }}
{{< /code >}}
## Template Example: TOC Partial
## Template example: TOC partial
The following is a [partial template][partials] that adds slightly more logic for page-level control over your table of contents. It assumes you are using a `toc` field in your content's [front matter] that, unless specifically set to `false`, will add a TOC to any page with a `.WordCount` (see [Page Variables][pagevars]) greater than 400. This example also demonstrates how to use [conditionals] in your templating:
@@ -92,7 +92,7 @@ In the header of your content file, specify the AsciiDoc TOC directives necessar
```asciidoc
// <!-- Your front matter up here -->
:toc:
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] configuration key
:toclevels: 4
== Introduction
+2 -2
View File
@@ -1,5 +1,5 @@
---
title: Content Types
title: Content types
description: Hugo is built around content organized in sections.
categories: [content management]
keywords: [lists, sections, content types, types, organization]
@@ -16,5 +16,5 @@ A **content type** is a way to organize your content. Hugo resolves the content
A content type is used to
- Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](https://gohugo.io/templates/views) for more.
- Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](/templates/views) for more.
- Determine which [archetype](/content-management/archetypes/) template to use for new content.
+5 -5
View File
@@ -1,5 +1,5 @@
---
title: URL Management
title: URL management
description: Control the structure and appearance of URLs through front matter entries and settings in your site configuration.
categories: [content management]
keywords: [aliases,redirects,permalinks,urls]
@@ -93,7 +93,7 @@ In your site configuration, define a URL pattern for each top-level section. Eac
Front matter `url` values override the URL patterns defined in the `permalinks` section of your site configuration.
[page kind]: https://gohugo.io/templates/section-templates/#page-kinds
[page kind]: /templates/section-templates/#page-kinds
#### Monolingual examples {#permalinks-monolingual-examples}
@@ -271,10 +271,10 @@ Use these tokens when defining the URL pattern. The `date` field in front matter
: the content's slug (or title if no slug is provided in the front matter)
`:slugorfilename`
: the content's slug (or filename if no slug is provided in the front matter)
: the content's slug (or file name if no slug is provided in the front matter)
`:filename`
: the content's filename (without extension)
: the content's file name (without extension)
For time-related values, you can also use the layout string components defined in Go's [time package]. For example:
@@ -383,7 +383,7 @@ In a multilingual site, use a directory-relative alias, or include the language
aliases = ['/de/posts/previous-file-name']
{{< /code-toggle >}}
### How Aliases Work
### How aliases work
Using the first example above, Hugo generates the following site structure:
+5 -4
View File
@@ -1,14 +1,15 @@
---
title: Contribute to the Hugo Project
linktitle: Contribute to Hugo
title: Contribute to the Hugo project
linkTitle: Overview
description: Contribute to Hugo development and documentation.
categories: [contribute]
keywords: []
menu:
docs:
identifier: contribute-overview
parent: contribute
weight: 01
weight: 01
weight: 10
weight: 10
aliases: [/tutorials/how-to-contribute-to-hugo/,/community/contributing/]
---
+12 -12
View File
@@ -1,14 +1,14 @@
---
title: Contribute to Hugo Development
linktitle: Development
title: Contribute to development
linkTitle: Development
description: Hugo relies heavily on contributions from the open source community.
categories: [contribute]
keywords: [dev,open source]
menu:
docs:
parent: contribute
weight: 10
weight: 10
weight: 20
weight: 20
toc: true
---
@@ -33,7 +33,7 @@ The installation of Go should take only a few minutes. You have more than one op
If you are having trouble following the installation guides for Go, check out [Go Bootcamp, which contains setups for every platform][gobootcamp] or reach out to the Hugo community in the [Hugo Discussion Forums][forums].
### Install Go From Source
### Install Go from source
[Download the latest stable version of Go][godl] and follow the official [Go installation guide][goinstall].
@@ -71,11 +71,11 @@ More experienced users can use the [Go Version Manager][gvm] (GVM). GVM allows y
GVM comes in especially handy if you follow the development of Hugo over a longer period of time. Future versions of Hugo will usually be compiled with the latest version of Go. Sooner or later, you will have to upgrade if you want to keep up.
## Create a GitHub Account
## Create a GitHub account
If you're going to contribute code, you'll need to have an account on GitHub. Go to [www.github.com/join](https://github.com/join) and set up a personal account.
## Install Git on Your System
## Install Git on your system
You will need to have Git installed on your computer to contribute to Hugo development. Teaching Git is outside the scope of the Hugo docs, but if you're looking for an excellent reference to learn the basics of Git, we recommend the [Git book][gitbook] if you are not sure where to begin. We will include short explanations of the Git commands in this document.
@@ -87,11 +87,11 @@ Move back to the terminal and check if Git is already installed. Type in `git ve
Finally, check again with `git version` if Git was installed successfully.
### Git Graphical Front Ends
### Git graphical front ends
There are several [GUI clients](https://git-scm.com/downloads/guis) that help you to operate Git. Not all are available for all operating systems and maybe differ in their usage. Because of this we will document how to use the command-line, since the commands are the same everywhere.
### Install Hub on Your System (Optional)
### Install Hub on your system (optional)
Hub is a great tool for working with GitHub. The main site for it is [hub.github.com](https://hub.github.com/). Feel free to install this little Git wrapper.
@@ -208,7 +208,7 @@ origin https://github.com/gohugoio/hugo (fetch)
origin https://github.com/gohugoio/hugo (push)
```
## The Hugo Git Contribution Workflow
## The Hugo Git contribution workflow
### Create a new branch
@@ -229,7 +229,7 @@ git checkout -b <BRANCH-NAME>
You can check on which branch you are with `git branch`. You should see a list of all local branches. The current branch is indicated with a little asterisk.
### Contribute to Documentation
### Contribute to documentation
Perhaps you want to start contributing to the Hugo docs. If so, you can ignore most of the following steps and focus on the `/docs` directory within your newly cloned repository. You can change directories into the Hugo docs using `cd docs`.
@@ -408,7 +408,7 @@ Thank you for reading through this contribution guide. Hopefully, we will see yo
Feel free to [open an issue][newissue] if you think you found a bug or you have a new idea to improve Hugo. We are happy to hear from you.
## Additional References for Learning Git and Go
## Additional references for learning Git and Go
* [Codecademy's Free "Learn Git" Course][codecademy] (Free)
* [Code School and GitHub's "Try Git" Tutorial][trygit] (Free)
+4 -4
View File
@@ -1,15 +1,15 @@
---
title: Contribute to the Hugo Docs
linktitle: Documentation
title: Contribute to documentation
linkTitle: Documentation
description: Documentation is an integral part of any open source project. The Hugo documentation is as much a work in progress as the source it attempts to cover.
categories: [contribute]
keywords: [docs,documentation,community, contribute]
menu:
docs:
parent: contribute
weight: 20
weight: 30
toc: true
weight: 20
weight: 30
aliases: [/contribute/docs/]
---
+5 -5
View File
@@ -1,14 +1,14 @@
---
title: Add Your Hugo Theme to the Showcase
linktitle: Themes
title: Add your hugo theme to the showcase
linkTitle: Themes
description: If you've built a Hugo theme and want to contribute back to the Hugo Community, share it with us.
categories: [contribute]
keywords: [contribute,themes,design]
menu:
docs:
parent: contribute
weight: 30
weight: 30
weight: 40
weight: 40
aliases: [/contribute/theme/]
toc: true
---
@@ -17,7 +17,7 @@ A collection of all themes created by the Hugo community, including screenshots
Another great site for Hugo themes is [jamstackthemes.dev/](https://jamstackthemes.dev/ssg/hugo/).
### Add Your Theme to the Repo
### Add your theme to the repository
In order to add your Hugo theme to [themes.gohugo.io] please [open a pull request in the theme repository](https://github.com/gohugoio/hugoThemesSiteBuilder). **Please make sure that you've read the theme submission guidelines in the [README](https://github.com/gohugoio/hugoThemesSiteBuilder/blob/main/README.md#hugo-themes) of the hugoThemesSiteBuilder repository.**
+3 -3
View File
@@ -1,11 +1,11 @@
---
title: Hugo Documentation
linktitle: Hugo
linkTitle: Hugo
description: Hugo is the world's fastest static website engine. It's written in Go (aka Golang) and developed by bep, spf13 and friends.
menu:
main:
weight: 01
weight: 01
weight: 1
weight: 1
layout: documentation-home
---
+4 -4
View File
@@ -37,15 +37,15 @@ And since `Page` also provides a `.GetPage` method, the above is the same as:
{{ end }}
```
## .GetPage and Multilingual Sites
## .GetPage and multilingual sites
The previous examples have used the full content filename to look up the post. Depending on how you have organized your content (whether you have the language code in the file name or not, e.g. `my-post.en.md`), you may want to do the lookup without extension. This will get you the current language's version of the page:
The previous examples have used the full content file name to look up the post. Depending on how you have organized your content (whether you have the language code in the file name or not, e.g. `my-post.en.md`), you may want to do the lookup without extension. This will get you the current language's version of the page:
```go-html-template
{{ with .Site.GetPage "/blog/my-post" }}{{ .Title }}{{ end }}
```
## .GetPage Example
## .GetPage example
This code snippet---in the form of a [partial template][partials]---allows you to do the following:
@@ -63,7 +63,7 @@ This code snippet---in the form of a [partial template][partials]---allows you t
</ul>
{{< /code >}}
## `.GetPage` on Page Bundles
## `.GetPage` on page bundles
If the page retrieved by `.GetPage` is a [Leaf Bundle][leaf_bundle], and you
need to get the nested _**page** resources_ in that, you will need to use the
+5 -2
View File
@@ -1,11 +1,14 @@
---
title: Functions Quick Reference
title: Functions
linkTitle: Overview
description: Comprehensive list of Hugo templating functions, including basic and advanced usage examples.
keywords: []
menu:
docs:
identifier: functions-overview
parent: functions
weight: 01
weight: 10
weight: 10
aliases: [/layout/functions/,/templates/functions]
---
+7 -7
View File
@@ -13,11 +13,11 @@ relatedfuncs: [now]
```go-html-template
{{ $d := "2022-01-01" | time.AsTime }}
{{ $d.AddDate 0 0 1 | time.Format "2006-01-02" }} --> 2022-01-02
{{ $d.AddDate 0 1 1 | time.Format "2006-01-02" }} --> 2022-02-02
{{ $d.AddDate 1 1 1 | time.Format "2006-01-02" }} --> 2023-02-02
{{ $d.AddDate 0 0 1 | time.Format "2006-01-02" }} 2022-01-02
{{ $d.AddDate 0 1 1 | time.Format "2006-01-02" }} 2022-02-02
{{ $d.AddDate 1 1 1 | time.Format "2006-01-02" }} 2023-02-02
{{ $d.AddDate -1 -1 -1 | time.Format "2006-01-02" }} --> 2020-11-30
{{ $d.AddDate -1 -1 -1 | time.Format "2006-01-02" }} 2020-11-30
```
{{% note %}}
@@ -28,11 +28,11 @@ See [this explanation](https://github.com/golang/go/issues/31145#issuecomment-47
```go-html-template
{{ $d := "2023-01-31" | time.AsTime }}
{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} --> 2023-03-03
{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} 2023-03-03
{{ $d := "2024-01-31" | time.AsTime }}
{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} --> 2024-03-02
{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} 2024-03-02
{{ $d := "2024-02-29" | time.AsTime }}
{{ $d.AddDate 1 0 0 | time.Format "2006-01-02" }} --> 2025-03-01
{{ $d.AddDate 1 0 0 | time.Format "2006-01-02" }} 2025-03-01
```
+2 -2
View File
@@ -20,7 +20,7 @@ The following shows `after` being used in conjunction with the [`slice` function
→ ["three", "four"]
```
## Example of `after` with `first`: 2nd&ndash;4th Most Recent Articles
## Example of `after` with `first`: 2nd&ndash;4th most recent articles
You can use `after` in combination with the [`first` function] and Hugo's [powerful sorting methods][lists]. Let's assume you have a list page at `example.com/articles`. You have 10 articles, but you want your templating for the [list/section page] to show only two rows:
@@ -33,7 +33,7 @@ You can use `after` in combination with the [`first` function] and Hugo's [power
<h2>Featured Article</h2>
{{ range first 1 .Pages.ByPublishDate.Reverse }}
<header>
<h3><a href="{{ . Permalink }}">{{ .Title }}</a></h3>
<h3><a href="{{ .Permalink }}">{{ .Title }}</a></h3>
</header>
<p>{{ .Description }}</p>
{{ end }}
+8 -8
View File
@@ -1,6 +1,6 @@
---
title: anchorize
description: Takes a string and sanitizes it the same way as the [`defaultMarkdownHandler`](https://gohugo.io/getting-started/configuration-markup#configure-markup) does for markdown headers.
description: Takes a string and sanitizes it the same way as the [`defaultMarkdownHandler`](/getting-started/configuration-markup#configure-markup) does for markdown headers.
categories: [functions]
menu:
docs:
@@ -10,15 +10,15 @@ signature: ["anchorize INPUT"]
relatedfuncs: [humanize]
---
If [Goldmark](https://gohugo.io/getting-started/configuration-markup#goldmark) is set as `defaultMarkdownHandler`, the sanitizing logic adheres to the setting [`markup.goldmark.parser.autoHeadingIDType`](https://gohugo.io/getting-started/configuration-markup#goldmark).
If [Goldmark](/getting-started/configuration-markup#goldmark) is set as `defaultMarkdownHandler`, the sanitizing logic adheres to the setting [`markup.goldmark.parser.autoHeadingIDType`](/getting-started/configuration-markup#goldmark).
Since the `defaultMarkdownHandler` and this template function use the same sanitizing logic, you can use the latter to determine the ID of a header for linking with anchor tags.
```go-html-template
{{ anchorize "This is a header" }} --> "this-is-a-header"
{{ anchorize "This is also a header" }} --> "this-is-also----a-header"
{{ anchorize "main.go" }} --> "maingo"
{{ anchorize "Article 123" }} --> "article-123"
{{ anchorize "<- Let's try this, shall we?" }} --> "--lets-try-this-shall-we"
{{ anchorize "Hello, 世界" }} --> "hello-世界"
{{ anchorize "This is a header" }} "this-is-a-header"
{{ anchorize "This is also a header" }} "this-is-also----a-header"
{{ anchorize "main.go" }} "maingo"
{{ anchorize "Article 123" }} "article-123"
{{ anchorize "<- Let's try this, shall we?" }} "--lets-try-this-shall-we"
{{ anchorize "Hello, 世界" }} "hello-世界"
```
+8
View File
@@ -26,4 +26,12 @@ The same example appending a slice to a slice:
{{ $s = $s | append (slice "d" "e") }}
```
If a slice contains other slices, further slices will be appended as values:
```go-html-template
{{ $s := slice (slice "a" "b") (slice "c" "d") }}
{{ $s = $s | append (slice "e" "f") (slice "g" "h") }}
{{/* $s now contains a [][]string containing four slices: ["a" "b"], ["c" "d"], ["e" "f"], and ["g" "h"] */}}
```
The `append` function works for all types, including `Pages`.
+1 -1
View File
@@ -1,6 +1,6 @@
---
title: apply
description: Given a map, array, or slice, `apply` returns a new slice with a function applied over it.
description: Given an array or slice, `apply` returns a new slice with a function applied over it.
categories: [functions]
menu:
docs:
@@ -0,0 +1,3 @@
+++
headless = true
+++
@@ -0,0 +1,8 @@
When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes.
Go's regular expression package implements the [RE2 syntax]. The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. Note that the RE2 `\C` escape sequence is not supported.
[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats
[PCRE]: https://www.pcre.org/
[RE2 syntax]: https://github.com/google/re2/wiki/Syntax/
[string literal]: https://go.dev/ref/spec#String_literals
+1 -1
View File
@@ -18,7 +18,7 @@ Note that the `key` can be either a `string` or a `string slice`. The latter is
{{ $m := dict (slice "a" "b" "c") "value" }}
```
## Example: Using `dict` to pass multiple values to a `partial`
## Example: using `dict` to pass multiple values to a `partial`
The partial below creates an SVG and expects `fill`, `height` and `width` from the caller:
+2 -2
View File
@@ -14,12 +14,12 @@ relatedfuncs: []
See the [Emoji cheat sheet][emojis] for available emoticons.
The `emojify` function can be called in your templates but not directly in your content files by default. For emojis in content files, set `enableEmoji` to `true` in your site's [configuration][config]. Then you can write emoji shorthand directly into your content files; e.g. <code>I :</code><code>heart</code><code>: Hugo!</code>:
The `emojify` function can be called in your templates but not directly in your content files by default. For emojis in content files, set `enableEmoji` to `true` in your site's [configuration]. Then you can write emoji shorthand directly into your content files; e.g. <code>I :</code><code>heart</code><code>: Hugo!</code>:
I :heart: Hugo!
[config]: /getting-started/configuration/
[configuration]: /getting-started/configuration/
[emojis]: https://www.webfx.com/tools/emoji-cheat-sheet/
[sc]: /templates/shortcode-templates/
[scsource]: https://github.com/gohugoio/hugo/tree/master/docs/layouts/shortcodes
+1 -1
View File
@@ -40,6 +40,6 @@ This will produce:
```
ERROR 2021/06/07 17:47:38 You should consider fixing this.
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site configuration:
ignoreErrors = ["my-custom-error"]
```
+7 -7
View File
@@ -24,11 +24,11 @@ content/
The function returns these values:
```go-html-template
{{ os.FileExists "content" }} --> true
{{ os.FileExists "content/news" }} --> true
{{ os.FileExists "content/news/article-1" }} --> false
{{ os.FileExists "content/news/article-1.md" }} --> true
{{ os.FileExists "news" }} --> true
{{ os.FileExists "news/article-1" }} --> false
{{ os.FileExists "news/article-1.md" }} --> true
{{ os.FileExists "content" }} true
{{ os.FileExists "content/news" }} true
{{ os.FileExists "content/news/article-1" }} false
{{ os.FileExists "content/news/article-1.md" }} true
{{ os.FileExists "news" }} true
{{ os.FileExists "news/article-1" }} false
{{ os.FileExists "news/article-1.md" }} true
```
+1 -15
View File
@@ -13,21 +13,7 @@ relatedfuncs: [findRESubmatch, replaceRE]
---
By default, `findRE` finds all matches. You can limit the number of matches with an optional LIMIT parameter.
When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes.
[string literal]: https://go.dev/ref/spec#String_literals
This function uses the [RE2] regular expression library. See the [RE2 syntax documentation] for details. Note that the RE2 `\C` escape sequence is not supported.
[RE2]: https://github.com/google/re2/
[RE2 syntax documentation]: https://github.com/google/re2/wiki/Syntax/
{{% note %}}
The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats].
[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats
[PCRE]: https://www.pcre.org/
{{% /note %}}
{{% readfile file="/functions/common/regular-expressions.md" %}}
This example returns a slice of all second level headings (`h2` elements) within the rendered `.Content`:

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