Closed (fixed)
Project:
Simple XML sitemap
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
3 May 2017 at 13:10 UTC
Updated:
27 Oct 2017 at 15:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
gbyteHave you tried going to
admin/config/search/simplesitemapand checking the checkboxSkip non-existent translations?Comment #3
hmartens commentedHi, yes i did. I don't know if it's the right approach but I went into Languages and deleted English and now the /en is gone but I do not know if some of my content was deleted ;)
Comment #4
hmartens commentedIt would be awesome if there were a tick box to select what languages you want in your sitemap. Or perhaps an exclude field where you can add paths to exclude?
Thank you for a great module!
Comment #5
ziomizar commentedMaybe we can change this in a feature request?
IMHO we need this functionality at least for the home page and views.
Scenario:
- I have two languages on my website english and german.
- Default language is german but i also have some pages ready to be published in english.
- I have 3 views : posts, jobs, news
- In my sitemap custom path i have to add : /, /post, /jobs and /news because these paths are not added automatically.
Sitemap.xml return:
- /post, /post/en
- /jobs, /jobs/en
- /news, /news/en
- /, /en
Also if the translation of views don't have results and is not listed into the custom links.
Would be great have a textarea identical to "custom links" where we can write "excluded links".
In this way in our scenario we can write in "excluded links" textarea:
- /jobs/en
- /post/en
- /news/en
- /en
To have a correct sitemaps.
Comment #6
gbyteWhere do you see the benefit of the sitemap not showing all language combinations for homepage or other non-entity pages? I think the better approach is to make the non-entity pages indexed with all languages (current implementation). If the site is not meant to be shown in another language, that language should not be there in the first place.
Comment #7
gbyteComment #8
ziomizar commentedI agree with you and developer side would be better don't have unused languages.
Anyway i see a benefit just when we are preparing a new language for a website that is not ready yet in this language.
Content editor already filled up contents but all these are unpublished.
When your approach is perfect for entity like content types and taxonomy we still have issues with frontpage and views that listing into sitemap translations that doesn't exists or are unpublished (so in these language are empty for example).
We are using now hook_simple_sitemap_links_alter to hide these links, but would be great don't write code to do that.
Comment #9
ziomizar commentedComment #10
maacl commentedSame as @ziomizar, we currently have two incomplete filled languages. First, because it takes time to get everything ready, and second we need approval from the client. So currently the language is blocked via htacess and robots.txt, to avoid indexing. It would be a nice feature to add a language to the sitemap when everything is ready.
Comment #11
gbyteI am still not convinced this is a needed feature. I don't believe there is any harm in the sitemap pointing to non-translated content. If there is, please correct me. Worst case, there is always a hook you can use. Feel free however to submit a patch with the required changes, I will be more than happy to review it.
Comment #12
zebda commentedI'm having the same problem. The thing is the site is live in Dutch at the moment and is going to be in English soon till then I don't want the /en in my sitemap. I see there is not going to be a definite fix for this but how can I write a hook to hide the /en links? I see there is this: hook_simple_sitemap_links_alter but how can I use it?
Comment #13
gbyte@zebda I've just updated the module's documentation pages with an example, please take a look.
@others Will gladly review/commit patches for this.
Comment #14
ziomizar commentedThis patch add a new tab "Disabled languages" on the simple sitemap settings.
Not sure if better add a textarea to exclude custom links, and call the whole section something like "Exclude".
Comment #15
gbyteThanks for the patch. Looking through it, I would change a couple of things:
UI:
Code:
excluded_languages: []Regarding your question, why would you want to exclude custom links?
Looking forward to the improvements.
Comment #16
ziomizar commentedMoving the settings into the Advanced settings section indeed simplify a lot the code, i've removed lot of stuff using the Settings form.
I'm not sure about to use a dropdown for this setting, as i want for sure select one or more languages, but not necessarily all of them.
All the points in Code section should be fixed, but I can't see how to use properly dependence injection in SitemapGenerator.php 319. I can't put the service in the simple_sitemap.services.yml because the circular reference. Should I call the setGenerator method in Batch.php finishGeneration()?
Comment #17
ziomizar commentedComment #18
ziomizar commentedRemoved unused router to the old form
Comment #19
gbyteI was thinking dropdown with multiple choice. I know this is more code to convert 'inluded languages' in the UI to 'excluded languages' storage and I am not sure if it is worth it. I think it is not that important, the UI part we can change any time.
You don't need to, the generator service is already injected, just use it:
Have you found a way to react on language delete events?
Now that excluded_languages is in simple_sitemap.settings, we can use the simple_sitemap API method to get and set it, so instead of
getExcludedLanguages(), just use simple_sitemap.generator service's getSetting('excluded_languages').What are your thoughts?
Comment #20
ziomizar commentedAgree, lets discuss about UI later.
When the sitemap generation run by Batch, $generator is not available, it is not defined by the constructor but using the setGenerator() method.
The cleanest way i saw until now to use it when Batch run, is
Good point about fire the deletion of a language. I've implemented hook_ENTITY_TYPE_delete() for 'configurable_language' and it works correctly. At the moment i'm just deleting the language from the settings and not regenerate the sitemap.
Comment #21
gbyteThanks for following up ziomizar.
I have made the following changes:
UrlGeneratorBase::addUrlVariants(), as it does not make much sense to let this method generate all language links to then remove them inSitemapGenerator::generateSitemapChunk()Please review the patch for me.
Comment #22
gbyteScrewed up the patch, here it goes again.
Comment #25
gbyteNo disagreement, so committing. Thanks @ziomizar.
Comment #26
ziomizar commentedMany thanks @gbyte!
Unfortunately havn't get time to work it more this week ;)