bolt / Sitemap

Bolt Sitemap extension - create XML sitemaps for your Bolt website.
MIT License
19 stars 20 forks source link

Generated Sitemap is incorrect with translate extension #38

Open Mahan-F opened 6 years ago

Mahan-F commented 6 years ago

I am using Sitemap version 2.3.0 and Translate version 4.1.1 on my Bolt website and the generated sitemap.xml file is using wrong URLs.

All URLs in my sitemap are like this:

<url>
<loc>http://www.website.com/en/en/pages</loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>

The language is repeated 2 times en/en/

Thierry75974 commented 6 years ago

I found a first workaround. In extensions/vendor/bolt/sitemap/templates/sitemap_xml.twig, you can replace

{{ url('homepage')|trim('/', 'right') }}{{ entry.link }}

by

{{ url('homepage')|trim('/', 'right') }}/{{ entry.link|trim('/', 'left')|split('/', 2)[1] }}
Mahan-F commented 6 years ago

@Thierry75974 Thanks! I'm going to use this fix for now.

quarryCodeDesign commented 6 years ago

@Thierry75974 - Thank you, @Mahan-F : you might be interested in this. Instead of what @Thierry75974 did above, I used:

{{ url('homepage')|trim('en', 'right') }}{{ entry.link|trim('/', 'left') }}

This specifically trimmed the first "en" out of the URL, leaving me with the properly formatted URL.

ankedsgn commented 5 years ago

Just for completeness's sake; This is still broken, using version 2.5.0. I'lll try the workaround for now, glad I checked if there was an issue for it.

What I did was: {{ url('homepage')|trim('/en', 'right')|trim('/nl', 'right') }} (trim all posible locales from the homepage slug. In my case en and nl)

Extra issue: When your slugs are translated (as they should be), the extension produces the wrong slug in every language but the default.

example: NL page: domain.nl/nl/naam-van-de-pagina EN page: domain.nl/en/name-of-the-page

In sitemap: domain.nl/nl/naam-van-de-pagina and domain.nl/en/naam-van-de-pagina

(Because the extension does not consider the en-slug and nl-slug)

bobdenotter commented 4 years ago

Should be fixed in release 2.6.0!

sylbru commented 4 years ago

I'm using animal/translate v4.2.1 and bolt/sitemap v2.6.0. I don't get any more URLs in my sitemap, just the pages in one locale (strangely, the second locale, not the default one). What am I missing?

I added the sitemap routes in routing.yml (as suggested in the readme) and it gives one sitemap per locale (/fr/sitemap.xml, /en/sitemap.xml). Is this the normal behavior? I was looking for a way of generating a truly multilingual sitemap, with <xhtml:link rel="alternate" … /> tags in each <url>.