Sitemap with url parameters instead of pages

Hi! I’m using the Siemap plugin by Cre8iv Click but I need that the certain pages on my site don’t use the post URL but instead use a custom one using the Kirby URL parameters, for example:

mysite.com/blogs/blog-title
should be
mysite.com/blog:blog-title

I tried to follow the cookbook for Routes, but it’s too advanced for me :frowning_face:

Any help understanding would be very much appreciated

thanks!

I think your best bet would probably to override the url()method in a page model. But whether or not that is feasible depends on what these “certain pages” are (do they share the same template, for example?) and whether this param style URL should be used not only in the sitemap but for the URLs of these pages in general.

I think i’m to noob for all these and have been building this site the wrong way :frowning:

The site uses the URL parameters to filter content on the home page, but the content is uploaded in particular pages. Each page contains a description, pictures and videos and the home allows you to see every video or filter the content of each page name. The idea is that each page is kept hidden and you can see the content only on the homepage using filters and URL parameters.

When I built it I didn’t consider the SEO, and now I’m completely lost trying to figure it out.

How can I learn to override the URL() method?

You would do it in a page model: https://getkirby.com/docs/guide/templates/page-models

If you want to override the url method of a page with an article template, you would create an article model

class ArticlePage extends Page {

  public function url($options = null): string {
    return site()->url() . '/whatever-follows-here';
  }
 
}

The important thing to keep in mind when overriding native methods in models is that you use the same signature as the original method (i.e. name, parameters and return types).

If you use multiple page types and need this for all, then you have to create a model for each page type.

Thanks! it works perfectly :slight_smile: