This issue is for porting the work presently getting done in #1670086: using rel="alternate" rather than multiple sitemaps by language context for D7 in D8.
As that issue hasn't officially been merged yet, I didn't want to cause confusion within that issue by posting the D8 port patch. So I've opted to create a separate issue instead of uploading the patch in there.
If the maintainers prefer though, this can be closed as a duplicate and I can post the patch there instead.
I'm gonna presume additional conversation will need to happen around D8 though.
Comment | File | Size | Author |
---|---|---|---|
#23 | 2941164-rel-alternate-cleanup.patch | 2.41 KB | Dave Reid |
| |||
#22 | 2941164-rel-alternate-cleanup.patch | 2.17 KB | Dave Reid |
| |||
#21 | 2941164-rel-alternate-cleanup.patch | 2.15 KB | Dave Reid |
#17 | 2941164-translated-rel-alternate.patch | 13.29 KB | Dave Reid |
| |||
#16 | 2941164-translated-rel-alternate.patch | 12.88 KB | Dave Reid |
|
Comments
Comment #2
WidgetsBurritos CreditAttribution: WidgetsBurritos as a volunteer and at Rackspace commentedThis patch isn't 100% complete... Just wanted to get an initial review to make sure it's generally okay. There are a few services that probably should get injected instead of referencing
\Drupal::
...Comment #4
manuel.adanSuch feature is present in the simple_sitemap module. I found it after spent several hours trying to make xmlsitemap run on a multilingual site with no success.
Comment #5
Dave ReidComment #6
Dave ReidComment #7
Dave ReidI think I can make this work in a backwards compatible way. I can rely implementing hook_xmlsitemap_element_alter() on behalf of content_moderation to inject the alternate links.
We will likely want to get rid of the language context eventually, likely in 2.0, since removing it would mean we need to inspect everyone's sitemap entities again, remove the context and then delete any duplicate sitemap entities.
I would *LOVE* some help testing this out.
Comment #8
Dave ReidI also wanted this to work automatically if there is only one sitemap created before the language module was enabled, and so the sitemap entity does not yet have a language context. This should help solve #3006297: When language module is installed, update sitemaps with language context.
Comment #9
Dave ReidFixing error in the latest patch.
Comment #10
Dave ReidBetter version that merges in the default contexts when loading the sitemap entities, instead of using language_xmlsitemap_context_alter(). That will make it compatible with all possible contexts. Still need to figure out what's going on with the test coverage.
Comment #11
Dave ReidLast patch did not have the cached changes only.
Comment #12
Dave ReidOMG it appears to be working all correctly!
Comment #13
Dave ReidWe were missing the
xmlns:xhtml="http://www.w3.org/1999/xhtml
attribute on the root XML, so let's just go ahead and add it globally.Comment #14
Dave ReidFixing test that no longer assumes we can set a sitemap to language undefined, that seems a bit silly.
Comment #15
Dave ReidI added support for ensuring that we also remove any invalid contexts in \Drupal\xmlsitemap\XmlSitemapStorage::doLoadMultiple(), fixed the empty context message on the sitemap edit form when there are contexts available, and also added alternate links for the homepage link.
Comment #16
Dave ReidGrr, new last one was just the same.
Comment #17
Dave ReidReduced repeated code by adding an internal function for adding alternate links.
Comment #19
Dave ReidOkay I feel really good about this. I'm going to go ahead and commit this to 8.x-1.x and I would *really* like some testing on the 8.x-1.x-dev branch from anyone who can!
Comment #20
Dave ReidI have found that if a translated node, is also linked in a menu_link_content item that is not translated, this means that likely the menu_link_content item is read first, and none of the alternate links are added in this case. I'll file a follow-up issue for this.
Comment #21
Dave ReidThis should help resolve it if we encounter a menu_link_content item for a node vs the node first in the xmlsitemap table in generation.
Comment #22
Dave ReidComment #23
Dave ReidFixing coding standards.
Comment #25
Dave ReidTested and committed #23 to 8.x-1.x.
Comment #26
Dave ReidThis has now been included in the 8.x-1.0-rc1 release, feedback and testing results would be welcome.