Why print date in listing pages though not define a date in frontmatter?

I am trying to implement a list template.
HUGO version is v0.80.0.
_index.md has not date property in frontmatter but a listing page renders date using the date property of a regular page in the same hierarchy.
Why does print a date?

I have the following structure:

.
├── branch_a
│   ├── _index.md <-- not have a date in frontmatter
│   └── foo.md <-- have a date in frontmatter
├── branch_b

layouts/_default/list.html looks like:

<ul>
{{- range (.Paginate .Sections).Pages -}}
  {{ if .Date }}<li>{{ .Title }}: {{ .Date }}</li>{{ end }}
{{- end -}}
<ul>

content/branch_a/_index.md:

---
title: Section A
---

content/branch_a/foo.md:

---
title: foo
date: '2016-05-16T22:46:57Z'
---

The rendering result(http://localhost:1313/branch_a/) is following as:

- Section A: 05/16/2016
- foo: 05/16/2016

Thank you in advance.

see different .Date attributes. You can define in CONFIG, how to get it.

PS: if you dont want the dates, remove {{ .Date }} from list template

1 Like

@ju52
Thank you for your answer!
I don’t know how to define different .Date attribute.

PS: if you dont want the dates, remove {{ .Date }} from list template

I wasn’t affected by definition about .Date, I’m thinking of removing it.
Thank you!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.