diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2024-04-14 10:04:36 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2024-04-14 11:22:13 +0200 |
| commit | aaad4f7b8fdd96573e9c3c3910d8c8a2c418841b (patch) | |
| tree | a792284fbd546db3f62f1cabeca39bdac2f2ddff /layouts/partials | |
| parent | 0c6aad8d28d9398dc36c70149e221f3af62203cc (diff) | |
| download | gohugo-theme-ed-aaad4f7b8fdd96573e9c3c3910d8c8a2c418841b.tar.gz | |
Use .Site.Lastmod if .Site.Hugo.Version greater than or equal to v0.123.0
Diffstat (limited to 'layouts/partials')
| -rw-r--r-- | layouts/partials/site-last-mod.html | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/layouts/partials/site-last-mod.html b/layouts/partials/site-last-mod.html new file mode 100644 index 0000000..ecd3900 --- /dev/null +++ b/layouts/partials/site-last-mod.html @@ -0,0 +1,21 @@ +{{- /* The .Site.LastChange was deprecated in Hugo v0.123.0 */ -}} +{{- /* Use .Site.Lastmod if .Site.Hugo.Version greater than or equal to v0.123.0 */ -}} +{{- /* Otherwise, use .Site.LastChange */ -}} + +{{- /* For more see: https://github.com/gohugoio/hugo/releases/tag/v0.123.0 */ -}} + +{{- /* Usage: {{ $siteLastMod := partial "site-last-mod.html" . }} */ -}} + +{{- $siteLastMod := "" -}} + +{{- if ge site.Hugo.Version "0.123.0" -}} + {{- if not site.Lastmod.IsZero -}} + {{- $siteLastMod = site.Lastmod -}} + {{- end -}} +{{- else -}} + {{- if not site.LastChange.IsZero -}} + {{- $siteLastMod = site.LastChange -}} + {{- end -}} +{{- end -}} + +{{- return $siteLastMod -}} |
