3

Site construct question...

I have categories. Craft knows where to find the template for a category - i.e. markets/{slug}.

But I also have a Markets (categories) page with the first 6 entries for each category (market). The template is markets/index.html.

The same holds true for and index page with all my entries. Craft knows where to find an entry posts/_entry - but what about the posts/index page?

How should these pages be setup/defined in Craft - should they be a single page or something else?

Background - Right now, they aren't defined in Craft - but I realize that I probably need to add them to work with an SEO plugin.

2 Answers 2

4

Depending on the rest of your site structure, yes you can set these up as Singles.

Your other option is to use an Entry Type inside a 'pages' Structure, and in that template you list the first 6 categories in a defined Category Group (possibly selected in a dropdown, or through craft.request.segment() )

Documentation link on how Craft looks for index templates in case it's useful: https://docs.craftcms.com/v3/templates.html#index-templates.

1
  • I found this question looking for a section id variable on the section/index template. It's not defined by default, but must be set manually.
    – ponies
    Commented May 5, 2020 at 17:14
2

Unless taking the structure route because there's a need for multiple index pages, I generally create a Single for each index page.

In your case I'd probably create two singles called 'Markets / Overview' and 'Pages / Overview'. I wouldn't display those titles necessarily in the template but I've found displaying 'Name of section / Overview' within the control panel helps the client.

This assumes the index page needs to be editable at all, but normally I find I need a couple of meta fields on every page on the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.