Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Sitemap is incorrect with translate extension #38

Open
Mahan-F opened this issue Feb 12, 2018 · 6 comments
Open

Generated Sitemap is incorrect with translate extension #38

Mahan-F opened this issue Feb 12, 2018 · 6 comments

Comments

@Mahan-F
Copy link

Mahan-F commented Feb 12, 2018

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
Copy link

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
Copy link
Author

Mahan-F commented Feb 24, 2018

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

@quarryCodeDesign
Copy link

@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
Copy link

ankedsgn commented Mar 11, 2019

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
Copy link
Member

Should be fixed in release 2.6.0!

@sylbru
Copy link

sylbru commented Nov 12, 2019

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>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants