Hello! I’ve been using Hugo for years, but some things still seem to elude me. Let’s say I’m trying to add a little pizzazz to my archive pages by adding an icon next to the section’s title. Here’s my section’s _index.md
:
---
title: "A clever title"
description: "A nice description."
icon: "😆"
---
This section.html
has always worked:
{{ define "main" }}
<header>
<h1>{{ .Title }}</h1>
{{ with .Description }}<p>{{ . }}</p>{{ end }}
</header>
<div class="content">
{{ range .Pages }}
<!-- More logic. -->
{{ end }}
</div>
{{ end }}
As soon as I do this, all hell breaks loose:
{{ define "main" }}
<header>
{{ with .Icon }}<p>{{ . }}</p>{{ end }}
<h1>{{ .Title }}</h1>
{{ with .Description }}<p>{{ . }}</p>{{ end }}
</header>
<div class="content">
{{ range .Pages }}
<!-- More logic. -->
{{ end }}
</div>
{{ end }}
Can someone explain what I’m missing?