Hugo is making me feel like a complete idiot. Sorry if the frustration is boiling over, but I’ve struggled a LONG time trying to grasp how to create one-off, stand-alone pages that are not a traditional blog page. For example, I want to build a website for a family member’s small business. I have similar needs as in this earlier support post:
Creating ‘static’ content that uses partials - support - HUGO
For example, I want to create a contact page with an embedded form, form validation scripts, things like that. Apart from the header and footer, this is a complete one-off page, no others will be like it. For me, I would like to create this page in HTML, but still use the partials and other features of Hugo’s templating system. And I got something to work. I’m not sure if this is a good way to do it, but it at least produces a page that I can control. In the /content
directory, I created a folder for contact, then added a _index.md file with basic front matter. I then created /layouts/contact/list.html
with my HTML in it. Not sure why list instead of single.html, but it works.
Now, I also want to create a section for various services they offer. As before, I created /content/services/_index.md
and /layouts/services/list.html
Now, my trouble begins because I want a series of other pages to live in this section. http://localhost:1313/services/
loads fine. but, I create /content/services/sprinklers.md
, with the expectation that http://localhost:1313/services/sprinklers would work. this produces a 404 error. I have no idea why.
I have read through Hugo’s Lookup Order | Hugo and Content Organization | Hugo several times. I just don’t get it. I’m not sure why, I just can not get my brain to process this, and I’m hoping someone can explain it to me a different way.
I’ve also tried specifying this in the front matter:
—
title: “Sprinklers”
type: services
layout: single
—
but that didn’t work for me.
Ultimately, I hope to finally understand the relationship between the /content/ directory and the /layouts/ directory. I want to create a URL like www.sitename.com/services - with a special HTML template for this section home page
- www.sitename.com/services/sprinklers - with a special HTML template for this section single pages
- www.sitename.com/services/landscaping - with a special HTML template for this section single pages
- And so on.
Right now, even when I do manage to get something to work, I’ve twisted my brain in so many circles I have no idea why it works. Any help would be greatly appreciated because I’m really struggling with this specific concept.
https://nifty-einstein-9d1275.netlify.com/ - a preview version of the site
GitHub - grizfan/bmls3 - a publicly available GitHub repo