diff --git a/content/en/commands/hugo.md b/content/en/commands/hugo.md index f521a2d1f..fa8f6d1ed 100644 --- a/content/en/commands/hugo.md +++ b/content/en/commands/hugo.md @@ -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) diff --git a/content/en/commands/hugo_completion_bash.md b/content/en/commands/hugo_completion_bash.md index 231804d09..875ecfc19 100644 --- a/content/en/commands/hugo_completion_bash.md +++ b/content/en/commands/hugo_completion_bash.md @@ -62,3 +62,4 @@ hugo completion bash ### SEE ALSO * [hugo completion](/commands/hugo_completion/) - Generate the autocompletion script for the specified shell + diff --git a/content/en/commands/hugo_config.md b/content/en/commands/hugo_config.md index e910a3235..3ec3748a3 100644 --- a/content/en/commands/hugo_config.md +++ b/content/en/commands/hugo_config.md @@ -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 diff --git a/content/en/commands/hugo_config_mounts.md b/content/en/commands/hugo_config_mounts.md index 59087c771..90b171912 100644 --- a/content/en/commands/hugo_config_mounts.md +++ b/content/en/commands/hugo_config_mounts.md @@ -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/) diff --git a/content/en/commands/hugo_mod_clean.md b/content/en/commands/hugo_mod_clean.md index 6ca413993..c1c2b0c0d 100644 --- a/content/en/commands/hugo_mod_clean.md +++ b/content/en/commands/hugo_mod_clean.md @@ -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*" diff --git a/content/en/commands/hugo_mod_graph.md b/content/en/commands/hugo_mod_graph.md index 55c95ca23..a2e2b51a3 100644 --- a/content/en/commands/hugo_mod_graph.md +++ b/content/en/commands/hugo_mod_graph.md @@ -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 diff --git a/content/en/commands/hugo_mod_init.md b/content/en/commands/hugo_mod_init.md index bef38c050..49b2609e1 100644 --- a/content/en/commands/hugo_mod_init.md +++ b/content/en/commands/hugo_mod_init.md @@ -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/) diff --git a/content/en/commands/hugo_mod_npm_pack.md b/content/en/commands/hugo_mod_npm_pack.md index 4f37f40df..30214d556 100644 --- a/content/en/commands/hugo_mod_npm_pack.md +++ b/content/en/commands/hugo_mod_npm_pack.md @@ -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/) diff --git a/content/en/commands/hugo_mod_tidy.md b/content/en/commands/hugo_mod_tidy.md index b28c6a3c2..803ef1c5b 100644 --- a/content/en/commands/hugo_mod_tidy.md +++ b/content/en/commands/hugo_mod_tidy.md @@ -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/) diff --git a/content/en/commands/hugo_mod_vendor.md b/content/en/commands/hugo_mod_vendor.md index 3df563621..3a829d5fd 100644 --- a/content/en/commands/hugo_mod_vendor.md +++ b/content/en/commands/hugo_mod_vendor.md @@ -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/) diff --git a/content/en/commands/hugo_mod_verify.md b/content/en/commands/hugo_mod_verify.md index 86f908564..b647a2cbb 100644 --- a/content/en/commands/hugo_mod_verify.md +++ b/content/en/commands/hugo_mod_verify.md @@ -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 diff --git a/content/en/commands/hugo_new_content.md b/content/en/commands/hugo_new_content.md index c7f87631c..dd646766b 100644 --- a/content/en/commands/hugo_new_content.md +++ b/content/en/commands/hugo_new_content.md @@ -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 diff --git a/content/en/commands/hugo_server.md b/content/en/commands/hugo_server.md index 601fd4406..49cd1867b 100644 --- a/content/en/commands/hugo_server.md +++ b/content/en/commands/hugo_server.md @@ -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 diff --git a/content/en/functions/where.md b/content/en/functions/where.md index af92619dc..f2e264235 100644 --- a/content/en/functions/where.md +++ b/content/en/functions/where.md @@ -73,6 +73,9 @@ The following logical operators are available with `where`: `intersect` : `true` if a given field value that is a slice/array of strings or integers contains elements in common with the matching value; it follows the same rules as the [`intersect` function][intersect]. +`like` +: `true` if a given field value matches a regular expression. Use the `like` operator to compare `string` values. Returns `false` when comparing other data types to the regular expression. + ## Use `where` with boolean values When using booleans you should not put quotation marks. ```go-html-template @@ -80,7 +83,6 @@ When using booleans you should not put quotation marks.

{{ .Title }}

{{ end }} ``` - ## Use `where` with `intersect` @@ -102,6 +104,31 @@ You can also put the returned value of the `where` clauses into a variable: {{ end }} {{< /code >}} +## Use `where` with `like` + +This example matches pages where the "foo" parameter begins with "ab": + +```go-html-template +{{ range where site.RegularPages "Params.foo" "like" "^ab" }} +

{{ .LinkTitle }}

+{{ end }} +``` + +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 + +Go's regular expression package implements the [RE2 syntax]. Note that the RE2 `\C` escape sequence is not supported. + +[RE2 syntax]: 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 %}} + ## Use `where` with `first` Using `first` and `where` together can be very diff --git a/content/en/getting-started/configuration.md b/content/en/getting-started/configuration.md index 91cdebd5b..21f4eb67f 100644 --- a/content/en/getting-started/configuration.md +++ b/content/en/getting-started/configuration.md @@ -824,7 +824,7 @@ You can override any of these cache settings in your own `hugo.toml`. ### The keywords explained `:cacheDir` -: This is the value of the `cacheDir` configuration option if set (can also be set via OS env variable `HUGO_CACHEDIR`). It will fall back to `/opt/build/cache/hugo_cache/` on Netlify, or a `hugo_cache_$USER` directory below the OS temp dir for the others. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see [this configuration](https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml). +: See [Configure cacheDir](#configure-cachedir). `:project` : The base directory name of the current Hugo project. This means that, in its default setting, every project will have separated file caches, which means that when you do `hugo --gc` you will not touch files related to other Hugo projects running on the same PC. @@ -853,3 +853,18 @@ dir [toml]: https://github.com/toml-lang/toml [yaml]: https://yaml.org/spec/ [static-files]: /content-management/static-files/ + + +# Configure cacheDir + +This is the directory where Hugo by default will store its file caches. See [Configure File Caches](#configure-file-caches). + +This can be set using the `cacheDir` config option or via the OS env variable `HUGO_CACHEDIR`. + +If this is not set, Hugo will use, in order of preference: + +1. If running on Netlify: `/opt/build/cache/hugo_cache/`. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see [this configuration](https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml). +1. In a `hugo_cache` directory below the OS user cache directory as defined by Go's [os.UserCacheDir](https://pkg.go.dev/os#UserCacheDir). On Unix systems, this is `$XDG_CONFIG_HOME` as specified by [basedir-spec-latest](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) if non-empty, else `$HOME/.config`. On MacOS, this is `$HOME/Library/Application Support`. On Windows, this is`%AppData%`. On Plan 9, this is `$home/lib`. {{< new-in "0.116.0" >}} +1. In a `hugo_cache_$USER` directory below the OS temp dir. + +If you want to know the current value of `cacheDir`, you can run `hugo config`, e.g: `hugo config | grep cachedir`. \ No newline at end of file