HUGO

How to use different templates for the same pages?

Hello people, I’m new to hugo. I wanted to build a page specifically for packages in which I wanted to show the packages that I’m offering to others.
I’ve placed the md files like
-Content
-Packages
-package-1.md
-package-2.md
-package-3.md

I’ve made a list file that shows all the packages and when you click on a package it takes you to the package page i.e /packages/package-1/

Now I want to package-3 to have a different template than package-1 and package-2.

I have made a single.html file and a list.html file.

layouts/
├── _default/
│   ├── baseof.html
│   ├── home.html
│   ├── list.html
│   └── single.html
└── packages/
    └── custom.html

content/packages/package-3.md

+++
title = 'Package 3`
date = 2021-11-12T14:28:26-08:00
draft = false
layout = 'custom'
+++

I suggest you keep your directory structure lowercase, and be consistent.

1 Like

Thankyou! It really helped.

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