How to set optional data page to route file?

I created my routes.yaml as below,

routes:
  /about/:
    template: about
    data: page.about-page

It works fine when exists a page in the database which has slug is ‘about-page’. But i want to know, how to set data page optionally?

Hey, there! Can you say more about what you’re trying to do?

I’m trying to set static routing with getting meta details from a page. I want to get meta data from the page if exist on the database. else executing with default meta data.

@RyanF Imagine a scenario where we need to override the SEO details of the template file using a “Ghost page” metadata section, but when there’s no page available the URL should show the template file instead of throwing an error when we define the route as in the above question so we can use the template file as it is. /about/ should show template: about regardless of availability of page page.about-page. Is there a way to do this?

1 Like

Sorry if I missed your reply — I’m still not sure I understand completely, but you don’t have to include the data property at all.

Otherwise, the dynamic routing docs contain all the info about what’s possible: