cache/filecache: Add a :project placeholder

This allows for "cache per Hugo project", making `hugo --gc` work as expected, even if you have several Hugo projects running on the same PC.

See #5439
This commit is contained in:
Bjørn Erik Pedersen
2018-11-14 17:18:32 +01:00
parent 3c29c5af8e
commit 94f0f7e597
5 changed files with 66 additions and 30 deletions

View File

@@ -413,10 +413,10 @@ Since Hugo 0.52 you can configure more than just the `cacheDir`. This is the def
```toml
[caches]
[caches.getjson]
dir = ":cacheDir"
dir = ":cacheDir/:project"
maxAge = -1
[caches.getcsv]
dir = ":cacheDir"
dir = ":cacheDir/:project"
maxAge = -1
[caches.images]
dir = ":resourceDir/_gen"
@@ -434,6 +434,9 @@ You can override any of these cache setting in your own `config.toml`.
:cacheDir
: This is the value of the `cacheDir` config 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` 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).
: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.
:resourceDir
: This is the value of the `resourceDir` config option.