hugo/content/functions/partialCached.md
Bjørn Erik Pedersen ec4e6f9df2 Squashed 'docs/' content from commit f887bd7b
git-subtree-dir: docs
git-subtree-split: f887bd7b4e3e7c7e76cd63951e5b0d37d8fe0ac7
2017-08-10 17:18:22 +02:00

1.4 KiB

title linktitle description godocref date publishdate lastmod categories menu signature workson hugoversion relatedfuncs deprecated aliases
partialCached partialCached Allows for caching of partials that do not need to be re-rendered on every invocation. 2017-02-01 2017-02-01 2017-02-01
functions
docs
parent
functions
partialCached LAYOUT INPUT [VARIANT...]
false

The partialCached template function can offer significant performance gains for complex templates that don't need to be re-rendered on every invocation. Here is the simplest usage:

{{ partialCached "footer.html" . }}

You can also pass additional parameters to partialCached to create variants of the cached partial. For example, if you have a complex partial that should be identical when rendered for pages within the same section, you could use a variant based upon section so that the partial is only rendered once per section:

{{< code file="partial-cached-example.html" >}} {{ partialCached "footer.html" . .Section }} {{< /code >}}

If you need to pass additional parameters to create unique variants, you can pass as many variant parameters as you need:

{{ partialCached "footer.html" . .Params.country .Params.province }}

Note that the variant parameters are not made available to the underlying partial template. They are only use to create a unique cache key.