mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-11 17:36:59 -04:00
content: Differentiate content view templates from other templates
This commit is contained in:
parent
978770fc8d
commit
172bfbc4b4
@ -38,7 +38,8 @@ layouts/
|
|||||||
│ ├── page.html
|
│ ├── page.html
|
||||||
│ └── section.html
|
│ └── section.html
|
||||||
├── films/
|
├── films/
|
||||||
│ ├── card.html <-- content view
|
│ ├── view_card.html <-- content view
|
||||||
|
│ ├── view_li.html <-- content view
|
||||||
│ ├── page.html
|
│ ├── page.html
|
||||||
│ └── section.html
|
│ └── section.html
|
||||||
├── baseof.html
|
├── baseof.html
|
||||||
@ -325,19 +326,21 @@ For example, Hugo applies a _base_ template to the _home_ template below, then r
|
|||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
<ul>
|
<ul>
|
||||||
{{ range where site.RegularPages "Section" "films" }}
|
{{ range where site.RegularPages "Section" "films" }}
|
||||||
{{ .Render "card" }}
|
{{ .Render "view_card" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
```go-html-template {file="layouts/films/card.html"}
|
```go-html-template {file="layouts/films/view_card.html"}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
|
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
|
||||||
{{ .Summary }}
|
{{ .Summary }}
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In the example above, the content view template's name starts with `view_`. While not strictly required, this naming convention helps distinguish content view templates from other templates within the same directory, improving organization and clarity.
|
||||||
|
|
||||||
## Render hook
|
## Render hook
|
||||||
|
|
||||||
A _render hook_ template overrides the conversion of Markdown to HTML.
|
A _render hook_ template overrides the conversion of Markdown to HTML.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user