getgrav / grav-plugin-sitemap

Grav Sitemap Plugin

Home Page:https://getgrav.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Related items not grouped in sitemap

marcocevoli opened this issue · comments

I've noticed that in v. 3.0 many pages are listed separately even though they belong to the same Grav page. See "politica-cookies", for instance (https://qabiria.com/politica-cookie): I have a single folder named "politica-cookie" with 3 files inside, default.en.md, default.it.md, default.es.md, where EN and ES are translations of the Italian file. They have a different slug, because - following best practices - I have translated all URLs.

I would expect 3 different elements in the sitemap, with cross-referenced rel="alternate" entries, but, instead, I do have 3 different but there is no relation between each other.

Is this an issue with the sitemap plugin or with Grav multilingual features?

Just checked and same on my sitemap. Looks like a bug, because in Google SEO recommendations example shows 3 pages <url>s each having 3 alternate links

Does look like a bug on your sitemaps.. I can't seem to replicate this on my own setups, so perhaps can one of put together a small sample set of 'pages' that exhibits this behavior so I can reproduce and fix?

Finally got to it 😅 So...

# site.yaml
default_lang: lt
# system.yaml
languages:
  supported:
    - lt
    - en
  default_lang: lt
  include_default_lang: false
  include_default_lang_file_extension: true
  override_locale: true
  content_fallback:
    en: en
  pages_fallback_only: true

Pages structure

/pages
  '- 02.typography
    |- default.en.md
    '- default.lt.md

Currently I have similar to this (removed last modified, priority and other tags for clarity):

  <url>
    <loc>http://playground.local/tipografija</loc>
    <xhtml:link rel="alternate" hreflang="lt" href="http://playground.local/tipografija" />
    <xhtml:link rel="alternate" hreflang="x-default" href="http://playground.local/tipografija" />
  </url>
  <url>
    <loc>http://playground.local/en/typography</loc>
    <xhtml:link rel="alternate" hreflang="en" href="http://playground.local/en/typography" />
  </url>

I expect sitemap to be something like this:

  <url>
    <loc>http://playground.local/tipografija</loc>
    <xhtml:link rel="alternate" hreflang="lt" href="http://playground.local/tipografija" />
    <xhtml:link rel="alternate" hreflang="en" href="http://playground.local/en/typography" />
  </url>
  <url>
    <loc>http://playground.local/en/typography</loc>
    <xhtml:link rel="alternate" hreflang="lt" href="http://playground.local/tipografija" />
    <xhtml:link rel="alternate" hreflang="en" href="http://playground.local/en/typography" />
  </url>

See this example on Google

FWIW here's my config:

languages:
  supported:
    - de
    - en
  default_lang: de
  include_default_lang: true
  include_default_lang_file_extension: true
  content_fallback:
    en: ['de']
    de: ['en']
  languages:
    http_accept_language: true

I have a page /legal/10.impressum/ with a default.de.md and a default.en.md. The latter has slug: imprint in the frontmatter.

In my sitemap I find two entries:

<url>
    <loc>http://localhost/cchp/de/legal/impressum</loc>
      <xhtml:link rel="alternate" hreflang="de" href="http://localhost/cchp/de/legal/impressum" />
      <xhtml:link rel="alternate" hreflang="x-default" href="http://localhost/cchp/de/legal/impressum" />
        <lastmod>2021-08-25</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
      </url>
<url>
    <loc>http://localhost/cchp/en/legal/imprint</loc>
      <xhtml:link rel="alternate" hreflang="en" href="http://localhost/cchp/en/legal/imprint" />
        <lastmod>2021-08-25</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
      </url>
commented

Hello, same problem here... Has anyone found a solution?