mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit '83bef6955e014d40c0f00db9cebe09113154e999'
This commit is contained in:
40
docs/content/en/functions/partialCached.md
Normal file
40
docs/content/en/functions/partialCached.md
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: partialCached
|
||||
linktitle: partialCached
|
||||
description: Allows for caching of partials that do not need to be re-rendered on every invocation.
|
||||
godocref:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [performance]
|
||||
signature: ["partialCached LAYOUT INPUT [VARIANT...]"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: []
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
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.
|
Reference in New Issue
Block a user