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

Built-in sitemap not working when using almost pretty permalinks #1107

Open
6 tasks done
Florian-Thake opened this issue Sep 9, 2022 · 5 comments
Open
6 tasks done

Comments

@Florian-Thake
Copy link

Florian-Thake commented Sep 9, 2022

Prerequisites

  • This is not a usage question (Those should be directed to the community supported forum, unless this is a question about Polylang Pro in which case you should use the helpdesk).
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of Polylang and the latest WordPress version.
  • This bug happens with only Polylang plugin active
  • This bug happens with a default WordPress theme active
  • I can reproduce this bug consistently

Steps to reproduce the issue

  1. Activate polylang. Have some pages and posts in 2 languages.
  2. Open the built-in sitemap: https://domain/wp-sitemap.xml
  3. Not display links for translations in list. Only the default / primary language is present. But each link is doubled.

Expected behavior and actual behavior

When I follow those steps, I see a list with sublinks to only the primary / default language. But each link is present 2 times.

I was expecting to see each sublink for the first and the second language.

Is there support for the built-in sitemap in Wordpress?

@Chouby
Copy link
Contributor

Chouby commented Sep 19, 2022

Yes, Polylang supports buil-in WP sitemap.

When you look at the content https://domain/wp-sitemap.xml, you should have something like:

http://domain/en/wp-sitemap-posts-post-1.xml
http://domain/fr/wp-sitemap-posts-post-1.xml
http://domain/en/wp-sitemap-posts-page-1.xml
http://domain/fr/wp-sitemap-posts-page-1.xml
http://domain/en/wp-sitemap-taxonomies-category-1.xml
http://domain/fr/wp-sitemap-taxonomies-category-1.xml
http://domain/en/wp-sitemap-users-1.xml
http://domain/fr/wp-sitemap-users-1.xml

Sor for example, you have one link for posts in English, one link for posts in French.
If you don't have this, please provide steps te reproduce (starting from a fresh install).

@Florian-Thake
Copy link
Author

Thank you for your reply. Unfortunately this is not the case on my page.
Instead I have all the links doubled, pointing to the same xml.
See attached screenshot.
Screenshot-sitemap

Do I have to change some settings?
Is it possible to re-build the built-in sitemap?

@Chouby
Copy link
Contributor

Chouby commented Sep 27, 2022

Thanks for the url of you site. This allowed me to understand the source of the bug and to reproduce it. It's due to the presence of index.php in your permalink settings. I did not take care to this case (to be honest, I'm quite sure I haven't seen a site with index.php in the urls in the past 10 years).

It works for me without index.php in the permalink settings. And to answer to your last question, the sitemap is built dynamically, so there's nothing to do to rebuild it.

@Chouby Chouby changed the title Built-in sitemap in Wordpress only contains the primary / default language links Built-in sitemap not working when using almost pretty permalinks Sep 27, 2022
@Chouby
Copy link
Contributor

Chouby commented Sep 27, 2022

Investigating this issue, I noticed that WordPress sitemaps don't follow the correct url pattern when adding index.php to the permalinks settings. The sitemap index is still accessible from https://example.org/wp-sitemap.xml when I expect it to be accessible from https://example.org/index.php/wp-sitemap.xml. It works correctly on a server with rewrite engine on (however adding index.php in permalinks settings has no practical interest in this case), but the sitemap doesn't work at all on a server with rewrite engine off.

I opened a new ticket for this bug: https://core.trac.wordpress.org/ticket/56671.

This needs to be checked after WordPress has solved this issue, but it's perfectly possible that this would solve the issue on our side at the same time as, when using almost pretty permalinks, Polylang expects that all urls include index.php and cannot deal with the current sitemap urls like https://example.org/wp-sitemap-posts-post-1.xml without the expected index.php

@Florian-Thake
Copy link
Author

Thanks for the url of you site. This allowed me to understand the source of the bug and to reproduce it. It's due to the presence of index.php in your permalink settings. I did not take care to this case (to be honest, I'm quite sure I haven't seen a site with index.php in the urls in the past 10 years).

It works for me without index.php in the permalink settings. And to answer to your last question, the sitemap is built dynamically, so there's nothing to do to rebuild it.

Thank you for your feedback and investigation! :)
I am new to Wordpress and I found the 'index.php' in the url very suspicious (who wants to know that the page is run with php? :-) ), but it was not important enough for me to spend some time with it.
I believe the 'index.php' was default set in the permalink settings as I started to build the page, or I changed it by accident.

Ok, to make a long story short: I removed the 'index.php' as the prefix from the permalink settings and now it works.
I can see the 2 languages in the sitemap with correct links. 👍

(Unfortunately I had to remove the 'index.php' from all manual placed internal links on the page. The links still work, but its cleaner to not have that 'index.php' anywhere. But this is not an issue of Polylang at all.)

So, for me the problem is solved by changing the permalink settings. Thank you again!

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

No branches or pull requests

2 participants