So I would create a route that matches all news category pages (assuming they all live in one dedicated folder so they can match a specific route) and then show the 404 page from that route with something like go('error')
?
I think the only built in way in Kirby would be to leave the content container as a draft.
That should trigger a 404. But I’m not sure your site hierarchy/templates allow for that.
As soon as it’s unlisted/listed it’s a page and has a public url.
@stffr I thought about keeping them as drafts, but I think that’s not a scalable solution. This will cause too much hassle to make sure all templates and fields using those categories expect all categories to be in draft status. And it’s not that convenient if you need to edit the content directly without using the panel.
You could keep the controller general and always redirect to the parent or home page. But again, I don’t know your whole site.
Yeah, that would be a workaround. Though redirecting to the homepage and not showing a proper 404 page is an antipattern and not good for SEO. I guess I can manually render the 404 page from the controller, at least I found some forum posts recommending this.
You can disable/remove the preview button as well.
Thanks, I missed that in the documentation, that’s definitely an improvement!
Do you need the content containers in your full url? Or is it just to structure your site? You could also remove the content container url with a route…
I just want to have some pages that store a reusable piece of content, but that don’t have their own page or URL in the frontend. For example, say you want to have Call-To-Action elements on your website that you want to define in one central location and only select which CTA to show on every page. As far as I can tell, the only way to unique refer to such a piece of content is to represent them with pages. But those CTA elements aren’t supposed to have their own URL – I don’t want to have a page /call-to-action/contact-us
, I just need that page as a way to store a headline, text and an email address that are gonna be displayed on a bunch of places but can be edited in one place.
This is a very common requirement (at least in our projects), so we’re looking for the recommended approach to do this in Kirby. Feels like if I have to manually add routes and render 404 pages that’s not very close to the intended usage. So I’m wondering how others are approaching this requirement and if there’s an easier solution.