Render other pages similarly to frontpage?

The homepage (templates/index.html) is rendered from the template without the need to have a corresponding content file (like content/home.md or content/index.md). Is this possible for other pages too ?

For example if I want a website like this:
example.com - homepage
example.com/features/ - a feature page
example.com/blog/ - blog with several posts stored in content

I’d rather have templates/features.html than
templates/features/single.html and content/features.md because the features template would only ever have one piece of content (thus, I’d rather just do its content with Go templating logic within features.html and skip the content/features.md entirely)

Reading the docs and trying things out, I didn’t get this to work. However, I believe this would be an excellent feature to allow Hugo to be used in sites that are more complex and not pure blogs / newsfeeds.

1 Like

Hi mate,

I was in the same position and luckily the question is already answered.

Check out this awesome @ChrisSLT comment on static page setup:

Read it few times. It is the recipe to robust landing pages on Hugo. I used this technique myself on Code and Send.

My /content/ directory is a mix of (static, landing-page) .html and .md files (articles). I have two taxonomies (don’t know if that’s a right term): /mag/ and /tests/; each is like a separate blog with its own article streams and custom front-matter structure. Also, I have purely static, perfected .html “about” pages coded using one-off responsive CSS. “About” pages are drawing template headers and footers common with other docs. When I update headers or add new meta tag, all my static pages update together with blog pages.

Definitely check out Chris’ post. It’s a must for any Hugo dev.

Best luck and let us know how it goes.

2 Likes

update. pasted the wrong article. It’s #19 by Chris not #18.

2 Likes

@royston thanks !

That is basically really close to what I’m doing right now so looks like I’m on the right track.

I would still prefer to use GO logic right in the content file itself (or just render the template directly without a content file). Not sure why having multiple pages render like the homepage would be a bad thing, but for some reason Hugo has decided not to go that way.

That method still requires that you do:

content/my_awesome_page.html
AND
layouts/my_awesome_page_type/single.html

instead of just:

content/my_awesome_page.html
(exclusive) OR
layouts/my_awesome_page.html

The good news in that is the type=something, layout=something1 trick which allows for better organisation of template files. If I understand correctly, no more need to do:

layouts/type1/single.html
layouts/type2/single.html
layouts/type3/single.html

but now I can

layouts/type/page1.html
layouts/type/page2.html
layouts/type/page3.html

correct ?