omz13/kirby3-xmlsitemap

Filter missing translations

mauricerenck opened this issue · 4 comments

It would be nice to exclude translations of pages which aren't existing (but showing the content of the original language).

Example:
I do have two languages enabled, german (default) and english. My podcast is german only, there is no translation. The sitemap lists the german posts, but it also lists urls to the english translation, which is not available. If you would open one of those urls you would see the german content (because it's the default lang).

On my site I do an extra check for that. So if you would open an non-existing translation, you'll get an 404 instead of the german content. But it would be nice, if those urls do not even appear in the sitemap.

In my templates I do the following, maybe this can be used in some way in your plugin, too:

foreach($page->translations() as $translation) { if($kirby->language()->code() == $translation->code() && !$page->translation($translation->code())->exists()) { go($translation->code() . '/error/' . $page->uid()); } }

This causes a 404 if the translation isn't available.

omz13 commented

Not a bad idea. I'll push out an update next week.

This option is not working for me.
I'm setting hideuntranslated to true but pages which is translated and the text file for this language exist still missing from sitemap. Any suggestions?

Thanks

I don't know if it's related somehow, but I have same content on my local and dev environment and see different results. 66 results on local and 74 on dev. I also see bad number of images for example article.

Thanks

Solved. Problem with plugin cache and namespace option.