Can I Use a Map for the title Field in Hugo's Front Matter?

Hello Hugo community!

I’m considering redefining the title field in Hugo’s front matter as a map instead of a string:

title:
  maintitle: "My Page Title"
  subtitle: "Subtitle"

Is there a way of doing this without without causing errors in Hugo? When I try to access the maintitle field by .Title.maintitle, I get the following error:

executing “_default/list.html” at <.Title.maintitle>: can’t evaluate field maintitle in type string

Thanks!

The title field in front matter is reserved. Do this instead:

---
title: My Page Title
subtitle: Subtitle
---
<h1>{{ .Title }}</h1>
<div>{{ .Params.subtitle }}</div>
1 Like

Sounds good! Thanks, @jmooring !