Custom template file for specific single page?

I’m trying to create a theme template for a specific page. I have a single page stored in content/contact.md and I would like to create a theme template for this page only as the design is different to other single pages.

I’ve followed the docs: https://gohugo.io/templates/lookup-order/ and attempted to place the following files. None work:

  • theme/mytheme/layouts/_default/contact.html
  • theme/mytheme/layouts/_default/contact.html.html
  • theme/mytheme/layouts/contact/single.html

In the template I have the following:

{{ define "main" }}
Testing, testing
{{ end }}

I’m expecting testing to be displayed, but it’s not and appears be using theme/mytheme/layouts/_default/single.html

I’ve tried adding: type: "contact" to the frontmatter but I still can’t get the contact page to use it’s own template. Any ideas?

Nope. We don’t know what’s in your content file, or config, or if there are other templates blocking it. Please share code as suggested, and we will figure it out. :slight_smile:

Try layout: contact

2 Likes