Some time ago, I actually already teased that I set up a landing page using Automad. Here I'll share how I did that (as I'm doing another project where I am doing this).
Context
So this guide applies when you have a large landing page for a website, one which you want to limit the content editors in what they can change/add (so not using the block system). But you do want to have specific styles per section based on some identifier. Than this should work.
Development
You make a landing_page.php file which will be assigned to the landing page (this can either be the default "Home page", but can be on any page of course.
In that page, you just add a new page list:
<main>
<@ newPagelist {
type: 'children',
excludeHidden: false,
context: '/homepage-sections'
} @>
<@ foreach in pagelist @>
<@ sections/about_us.php @>
<@ sections/how_we_can_help.php @>
<@ end @>
</main>
Some remarks:
- I've added the excludeHidden. This is due to the fact that you want to "hide" the "pages" that you are creating, as these are sections. So these should not show up in any navigation whatsoever. Also, I would advise you to redirect these pages to the actual landing page by filling the redirect URL in the backend.
- In my case, I have the following page structure: Home page > Home page sections > actual sections. So that's why I have added the context of /homepage-sections (the latter being the slug)
- Notice the different "section/*" files. Those are where the magic happens. Depending on how many sections you'll have here, this list becomes long
Make a directory "sections" and add (for example) the about_us.php file:
<@ if @{ :origUrl } = '/homepage-sections/about-us' @>
<section id="@{ :origUrl |
replace(
'/\\//',
''
)}">
<h2>
@{ title }
</h2>
<div>
@{ +about-us }
</div>
<div>
@{ about-us-closing-statement }
</div>
</section>
<@ end @>
Remarks:
- I do a check on origUrl, because due to the dynamic nature of the pagelist, the regular url just returns "/"
- I of course need to check for "homepage-sections" at the beginning of the origUrl
- Now, for each section, you can add specific fields that you want to add. It is best to start these with a specific value (as you can see above) so somebody can identify these pages
- I have created a "section" page, which I set as the style of the section pages. That file has nothing in it. This way, there is no metadata added to those page, preventing any problems with content editors expecting something to happen
When you set it up like this, you can create different styles for each section and add the necessary values where necessary. What might work is if you create separate pages per section and add the custom variables there. Than users can change the values on each page, but the variables would still show up on the home page too. So not sure how that works.
I know the above is quite an abstract/high-over concept, but I hope it makes sense, as it really is nothing more than a concept... any input is more than welcome!