mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 21:51:02 +03:00
Merge commit '9b0050e9aa
' as 'docs'
``` git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash ``` Closes #11925
This commit is contained in:
commit
5fd1e74903
1158 changed files with 64103 additions and 0 deletions
27
docs/content/en/functions/templates/Exists.md
Normal file
27
docs/content/en/functions/templates/Exists.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
title: templates.Exists
|
||||
description: Reports whether a template file exists under the given path relative to the layouts directory.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related: []
|
||||
returnType: bool
|
||||
signatures: [templates.Exists PATH]
|
||||
aliases: [/functions/templates.exists]
|
||||
---
|
||||
|
||||
A template file is any file within the `layouts` directory of either the project or any of its theme components.
|
||||
|
||||
Use the `templates.Exists` function with dynamic template paths:
|
||||
|
||||
```go-html-template
|
||||
{{ $partialPath := printf "headers/%s.html" .Type }}
|
||||
{{ if templates.Exists ( printf "partials/%s" $partialPath ) }}
|
||||
{{ partial $partialPath . }}
|
||||
{{ else }}
|
||||
{{ partial "headers/default.html" . }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
In the example above, if a "headers" partial does not exist for the given content type, Hugo falls back to a default template.
|
13
docs/content/en/functions/templates/_index.md
Normal file
13
docs/content/en/functions/templates/_index.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: Template functions
|
||||
linkTitle: templates
|
||||
description:
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
identifier: templates-functions
|
||||
parent: functions
|
||||
---
|
||||
|
||||
Use these functions to query the template system.
|
Loading…
Add table
Add a link
Reference in a new issue