How to use functional helpers to select index, with custom routing?

Just to clarify, the routes file should be named routes.yaml :blush:

I’m not entirely sure what SEO metadata you want to change, but here’s a method of applying your custom page title and pagination number:

Replace the {{meta_title}} in the default.hbs with the following:

<title>{{{block "title"}}}</title>

This will allow you to customise the page title in all templates. So in most cases you’ll want to set it to the meta_title. That can be done by adding the following to the template:

{{#contentFor "title"}}{{meta_title}}{{/contentFor}}

Meanwhile in your culture index.hbs template we can get a bit more clever. The pagination.page helper can give us the page count, but we can also use this count to identify if it’s the first page or not with the plural helper.

Putting that all together gives us something like this:

{{#contentFor "title"}}Culture{{plural pagination.page empty='' singular='' plural=' – (Page %)'}}{{/contentFor}}

The plural helper will return nothing if it’s page 1, but will return – (Page X) if it’s page 2 and over.

Hope this is clear enough for you. If not just say :v:

1 Like