vaersaagod/seomate

How to specify URL of sitemap entry

Closed this issue · 2 comments

Admittedly this is a little weird. But I have a section in my site where the entries power 2 pages each.

It's a section of people, and each can have 0, 1, or 2 pages associated with them. We have toggles on the entry to handle their creation.

The first page type is configured in the normal way with a conditional in the URL field so it's blank if the toggle is turned off. This works great with SeoMate's Sitemap.

The second page type is configured via the config/routes.php file. If you hit the route and pass it the slug of the entry, it does a lookup. If it doesn't exist or if the toggle is disabled it does an {% exit 404 %}. This works.

However, in hooking it into the sitemap I am unable to specify the URL. So it has the URL of the first page type. See here:

'videoPeople' => [
        'elementType' => \craft\elements\Entry::class,
        'criteria' => [
          'section' => 'people',
          'featureEnabled_DefaultOff' => true
        ],
        'params' => ['changefreq' => 'weekly', 'priority' => .7]
      ],

Is there something I can pass in the config to allow me to kind of hardcode the URL or something?

Have you looked at the additionalSitemaps config setting? Creating your own, custom sitemap containing links to these routed entries, is probably your best bet.

Oh that's a smart approach. I think I got a little lost in the trees, but this will work fine. Thank you!