Merge commit '230a495941b191af0bdaa7e2fc8c61607cb38207'

This commit is contained in:
Bjørn Erik Pedersen 2022-02-14 12:58:42 +01:00
commit c707b71cdf
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
13 changed files with 55 additions and 128 deletions

View file

@ -25,7 +25,7 @@ But when developing and building your site, the runtime is the `hugo` executable
* Hugo has a virtual file system and only the main project (not third-party components) is allowed to mount directories or files outside the project root.
* Only the main project can walk symbolic links.
* User-defined components have only read-access to the filesystem.
* 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.
@ -35,7 +35,7 @@ But when developing and building your site, the runtime is the `hugo` executable
Hugo has a built-in security policy that restricts access to [os/exec](https://pkg.go.dev/os/exec), remote communication and similar.
The default configuration is listed below. And build using features not whitelisted in the security policy will faill with a detailed message about what needs to be done. Most of these settings are whitelists (string or slice, [Regular Expressions](https://pkg.go.dev/regexp) or `none` which matches nothing).
The default configuration is listed below. Any build using features not in the allow list of the security policy will fail with a detailed message about what needs to be done. Most of these settings are allow lists (string or slice, [Regular Expressions](https://pkg.go.dev/regexp) or `none` which matches nothing).
{{< code-toggle config="security" />}}
@ -47,9 +47,9 @@ HUGO_SECURITY_HTTP_URLS=none hugo
## Dependency Security
Hugo builds 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 any transitive.
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 built on top of Go Modules functionality, and 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/).
[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

View file

@ -14,7 +14,7 @@ aliases: [/content/types]
toc: true
---
A **content type** is a way to organize your content. Hugo resolves the content type from either the `type` in front matter or, if not set, the first directory in the file path. E.g. `content/blog/my-first-event.md` will be of type `blog` if no `type` set.
A **content type** is a way to organize your content. Hugo resolves the content type from either the `type` in front matter or, if not set, the first directory in the file path. E.g. `content/blog/my-first-event.md` will be of type `blog` if no `type` is set.
A content type is used to

View file

@ -15,7 +15,7 @@ aliases: []
Example:
```go-html-template
{{ $pages := .Site.RegularPages | first 50 }}
{{ $pages := site.RegularPages | first 50 }}
{{ $news := where $pages "Type" "news" | first 5 }}
{{ $blog := where $pages "Type" "blog" | first 5 }}
{{ $other := $pages | complement $news $blog | first 10 }}

View file

@ -6,7 +6,7 @@ categories: [functions]
menu:
docs:
parent: "functions"
keywords: [collections,intersect,union, complement]
keywords: [collections,intersect,union,complement]
signature: ["COLLECTION | symdiff COLLECTION" ]
hugoversion: "0.51"
aliases: []

View file

@ -9,7 +9,7 @@ categories: [functions]
menu:
docs:
parent: "functions"
keywords: [filtering,lists]
keywords: [collections,intersect,union,complement]
signature: ["union SET1 SET2"]
workson: []
hugoversion: 0.20

View file

@ -393,18 +393,12 @@ Now you need to add Hugo to your Windows PATH settings:
* Right click on the **Start** button.
* Click on **System**.
* Click on **Advanced System Settings** on the left.
* Click on **Advanced System Settings** on the right.
* Click on the **Environment Variables...** button on the bottom.
* In the User variables section, find the row that starts with PATH (PATH will be all caps).
* Double-click on **PATH**.
* Click the **New...** button.
* Type in the folder where `hugo.exe` was extracted, which is `C:\Hugo\bin` if you went by the instructions above. *The PATH entry should be the folder where Hugo lives and not the binary.* Press <kbd>Enter</kbd> when you're done typing.
* In the User variables section, select the row labeled "Path" and click the **Edit...** button.
* Click the **Browse...** button and select the directory to which `hugo.exe` was extracted, which is `C:\Hugo\bin` if you went by the instructions above. *The path entry should be the folder where Hugo lives and not the binary itself.*
* Click OK at every window to exit.
{{% note "Path Editor in Windows 10"%}}
The path editor in Windows 10 was added in the large [November 2015 Update](https://blogs.windows.com/windowsexperience/2015/11/12/first-major-update-for-windows-10-available-today/). You'll need to have that or a later update installed for the above steps to work. You can see what Windows 10 build you have by clicking on the <i class="fa fa-windows"></i>&nbsp;Start button → Settings → System → About. See [here](https://www.howtogeek.com/236195/how-to-find-out-which-build-and-version-of-windows-10-you-have/) for more.)
{{% /note %}}
#### For Windows 7 and 8.x users:
Windows 7 and 8.1 do not include the easy path editor included in Windows 10, so non-technical users on those platforms are advised to install a free third-party path editor like [Windows Environment Variables Editor][Windows Environment Variables Editor] or [Path Editor](https://patheditor2.codeplex.com/).
@ -506,7 +500,7 @@ sudo pacman -Syu hugo
### Fedora, Red Hat and CentOS
Fedora maintains an [official package for Hugo](https://apps.fedoraproject.org/packages/hugo) which may be installed with:
Fedora maintains an [official package for Hugo](https://packages.fedoraproject.org/pkgs/hugo/hugo) which may be installed with:
sudo dnf install hugo

View file

@ -42,7 +42,7 @@ private
: Comma separated glob list matching paths that should be treated as private.
replacements {{< new-in "0.77.0" >}}
: A comma separated (or a slice) list of module path to directory replacement mapping, e.g. `"github.com/bep/myprettytheme -> ../..,github.com/bep/shortcodes -> /some/path`. This is mostly useful for temporary locally development of a module, and then it makes sense to set it as an OS environment variable, e.g: `env HUGO_MODULE_REPLACEMENTS="github.com/bep/myprettytheme -> ../.."`. Any relative path is relate to [themesDir](https://gohugo.io/getting-started/configuration/#all-configuration-settings), and absolute paths are allowed.
: A comma separated (or a slice) list of module path to directory replacement mapping, e.g. `github.com/bep/myprettytheme -> ../..,github.com/bep/shortcodes -> /some/path`. This is mostly useful for temporary locally development of a module, and then it makes sense to set it as an OS environment variable, e.g: `env HUGO_MODULE_REPLACEMENTS="github.com/bep/myprettytheme -> ../.."`. Any relative path is relate to [themesDir](https://gohugo.io/getting-started/configuration/#all-configuration-settings), and absolute paths are allowed.
Note that the above terms maps directly to their counterparts in Go Modules. Some of these setting may be natural to set as OS environment variables. To set the proxy server to use, as an example:

View file

@ -207,7 +207,7 @@ Currently, you can only use those authentication methods that can be put into an
To load local files with `getJSON` and `getCSV`, the source files must reside within Hugo's working directory. The file extension does not matter, but the content does.
It applies the same output logic as above in [Call the Functions with a URL](#call-the-functions-with-a-url).
It applies the same output logic as above in [Get Remote Data](#get-remote-data).
{{% note %}}
The local CSV files to be loaded using `getCSV` must be located **outside** of the `data` directory.

View file

@ -33,26 +33,25 @@ This allows a theme's end user to copy a partial's contents into a file of the s
All partials for your Hugo project are located in a single `layouts/partials` directory. For better organization, you can create multiple subdirectories within `partials` as well:
```
.
└── layouts
└── partials
├── footer
│   ├── scripts.html
│   └── site-footer.html
├── head
│   ├── favicons.html
│   ├── metadata.html
│   ├── prerender.html
│   └── twitter.html
└── header
├── site-header.html
└── site-nav.html
```txt
layouts/
└── partials/
├── footer/
│ ├── scripts.html
│ └── site-footer.html
├── head/
│ ├── favicons.html
│ ├── metadata.html
│ ├── prerender.html
│ └── twitter.html
└── header/
├── site-header.html
└── site-nav.html
```
All partials are called within your templates using the following pattern:
```
```go-html-template
{{ partial "<PATH>/<PARTIAL>.html" . }}
```
@ -66,7 +65,7 @@ One of the most common mistakes with new Hugo users is failing to pass a context
As shown in the above example directory structure, you can nest your directories within `partials` for better source organization. You only need to call the nested partial's path relative to the `partials` directory:
```
```go-html-template
{{ partial "header/site-header.html" . }}
{{ partial "footer/scripts.html" . }}
```
@ -81,22 +80,8 @@ This means the partial will *only* be able to access those variables. The partia
In addition to outputting markup, partials can be used to return a value of any type. In order to return a value, a partial must include a lone `return` statement.
## Inline partials
{{< new-in "0.74.0" >}}
You can also define partials inline in the template. But remember that template namespace is global, so you need to make sure that the names are unique to avoid conflicts.
```go-html-template
Value: {{ partial "my-inline-partial" . }}
{{ define "partials/my-inline-partial" }}
{{ $value := 32 }}
{{ return $value }}
{{ end }}
```
### Example GetFeatured
```go-html-template
{{/* layouts/partials/GetFeatured.html */}}
{{ return first . (where site.RegularPages "Params.featured" true) }}
@ -108,7 +93,9 @@ Value: {{ partial "my-inline-partial" . }}
[...]
{{ end }}
```
### Example GetImage
```go-html-template
{{/* layouts/partials/GetImage.html */}}
{{ $image := false }}
@ -132,11 +119,26 @@ Value: {{ partial "my-inline-partial" . }}
Only one `return` statement is allowed per partial file.
{{% /note %}}
## Inline Partials
{{< new-in "0.74.0" >}}
You can also define partials inline in the template. But remember that template namespace is global, so you need to make sure that the names are unique to avoid conflicts.
```go-html-template
Value: {{ partial "my-inline-partial" . }}
{{ define "partials/my-inline-partial" }}
{{ $value := 32 }}
{{ return $value }}
{{ end }}
```
## Cached Partials
The [`partialCached` template function][partialcached] can offer significant performance gains for complex templates that don't need to be re-rendered on every invocation. The simplest usage is as follows:
```
```go-html-template
{{ partialCached "footer.html" . }}
```
@ -144,13 +146,13 @@ You can also pass additional parameters to `partialCached` to create *variants*
For example, you can tell Hugo to only render the partial `footer.html` once per section:
```
```go-html-template
{{ partialCached "footer.html" . .Section }}
```
If you need to pass additional parameters to create unique variants, you can pass as many variant parameters as you need:
```
```go-html-template
{{ partialCached "footer.html" . .Params.country .Params.province }}
```

View file

@ -24,22 +24,14 @@ The following starter kits are developed by active members of the Hugo community
{{% /note %}}
* [Hugo Wrapper][hugow]. Hugo Wrapper is a POSIX-style shell script which acts as a wrapper to download and run Hugo binary for your platform. It can be executed in variety of [Operating Systems][hugow-test] and [Command Shells][hugow-test].
* [Victor Hugo][]. Victor Hugo is a Hugo boilerplate for creating truly epic websites using Webpack as an asset pipeline. Victor Hugo uses post-css and Babel for CSS and JavaScript, respectively, and is actively maintained.
* [GOHUGO AMP][]. GoHugo AMP is a starter theme that aims to make it easy to adopt [Google's AMP Project][amp]. The starter kit comes with 40+ shortcodes and partials plus automatic structured data. The project also includes a [separate site with extensive documentation][gohugodocs].
* [Blaupause][]. Blaupause is a developer-friendly Hugo starter kit based on Gulp tasks. It comes ES6-ready with several helpers for SVG and fonts and basic structure for HTML, SCSS, and JavaScript.
* [hugulp][]. hugulp is a tool to optimize the assets of a Hugo website. The main idea is to recreate the famous Ruby on Rails Asset Pipeline, which minifies, concatenates and fingerprints the assets used in your website.
* [Atlas][]. Atlas is a Hugo boilerplate designed to speed up development with support for Netlify, Hugo Pipes, SCSS & more. It's actively maintained and contributions are always welcome.
* [Hyas][]. Hyas is a Hugo starter helping you build modern websites that are secure, fast, and SEO-ready — by default. It is Netlify-ready (functions, redirects, headers) and comes with [documentation](https://gethyas.com/) to easily make it your own.
[addkit]: https://github.com/gohugoio/hugo/edit/master/docs/content/en/tools/starter-kits.md
[amp]: https://amp.dev
[Blaupause]: https://github.com/fspoettel/blaupause
[GOHUGO AMP]: https://github.com/wildhaber/gohugo-amp
[gohugodocs]: https://gohugo-amp.gohugohq.com/
[hugow]: https://github.com/khos2ow/hugo-wrapper
[hugow-test]: https://github.com/khos2ow/hugo-wrapper#tested-on
[hugulp]: https://github.com/jbrodriguez/hugulp
[Victor Hugo]: https://github.com/netlify/victor-hugo
[Atlas]: https://github.com/indigotree/atlas
[Hyas]: https://github.com/h-enk/hyas

View file

@ -1,49 +0,0 @@
---
title: Hugo-specific Variables
linktitle: Hugo Variables
description: The `.Hugo` variable provides easy access to Hugo-related data.
date: 2017-03-12
publishdate: 2017-03-12
lastmod: 2017-03-12
categories: [variables and params]
keywords: [hugo,generator]
draft: false
menu:
docs:
parent: "variables"
weight: 60
weight: 60
sections_weight: 60
aliases: []
toc: false
wip: false
---
{{% warning "Deprecated" %}}
Page's `.Hugo` is deprecated and will be removed in a future release. Use the global `hugo` function.
For example: `hugo.Generator`.
{{% /warning %}}
It contains the following fields:
.Hugo.Generator
: `<meta>` tag for the version of Hugo that generated the site. `.Hugo.Generator` outputs a *complete* HTML tag; e.g. `<meta name="generator" content="Hugo 0.18" />`
.Hugo.Version
: the current version of the Hugo binary you are using e.g. `0.13-DEV`<br>
.Hugo.Environment
: the current running environment as defined through the `--environment` cli tag.
.Hugo.CommitHash
: the git commit hash of the current Hugo binary e.g. `0e8bed9ccffba0df554728b46c5bbf6d78ae5247`
.Hugo.BuildDate
: the compile date of the current Hugo binary formatted with RFC 3339 e.g. `2002-10-02T10:00:00-05:00`<br>
{{% note "Use the Hugo Generator Tag" %}}
We highly recommend using `.Hugo.Generator` in your website's `<head>`. `.Hugo.Generator` is included by default in all themes hosted on [themes.gohugo.io](https://themes.gohugo.io). The generator tag allows the Hugo team to track the usage and popularity of Hugo.
{{% /note %}}

View file

@ -48,9 +48,6 @@ See [`.Scratch`](/functions/scratch/) for page-scoped, writable variables.
.Description
: the description for the page.
.Dir
: the path of the folder containing this content file. The path is relative to the `content` folder.
.Draft
: a boolean, `true` if the content is marked as a draft in the front matter.
@ -63,9 +60,6 @@ See [`.Scratch`](/functions/scratch/) for page-scoped, writable variables.
.FuzzyWordCount
: the approximate number of words in the content.
.Hugo
: see [Hugo Variables](/variables/hugo/).
.IsHome
: `true` in the context of the [homepage](/templates/homepage/).
@ -132,9 +126,6 @@ See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo].
.PublishDate
: the date on which the content was or will be published; `.Publishdate` pulls from the `publishdate` field in a content's front matter. See also `.ExpiryDate`, `.Date`, and `.Lastmod`.
.RSSLink (deprecated)
: link to the page's RSS feed. This is deprecated. You should instead do something like this: `{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}`.
.RawContent
: raw markdown content without the front matter. Useful with [remarkjs.com](
https://remarkjs.com)
@ -185,9 +176,6 @@ https://remarkjs.com)
.Type
: the [content type](/content-management/types/) of the content (e.g., `posts`).
.UniqueID (deprecated)
: the MD5-checksum of the content file's path. This variable is deprecated and will be removed, use `.File.UniqueID` instead.
.Weight
: assigned weight (in the front matter) to this content, used in sorting.

View file

@ -3,7 +3,7 @@ publish = "public"
command = "hugo --gc --minify"
[context.production.environment]
HUGO_VERSION = "0.91.2"
HUGO_VERSION = "0.92.2"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true"
command = "hugo --gc --minify --enableGitInfo"
[context.split1.environment]
HUGO_VERSION = "0.91.2"
HUGO_VERSION = "0.92.2"
HUGO_ENV = "production"
[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
[context.deploy-preview.environment]
HUGO_VERSION = "0.91.2"
HUGO_VERSION = "0.92.2"
[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
[context.branch-deploy.environment]
HUGO_VERSION = "0.91.2"
HUGO_VERSION = "0.92.2"
[context.next.environment]
HUGO_ENABLEGITINFO = "true"