grav-plugin-sitemap icon indicating copy to clipboard operation
grav-plugin-sitemap copied to clipboard

Related items not grouped in sitemap

Open marcocevoli opened this issue 4 years ago • 5 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?

marcocevoli avatar Feb 09 '21 18:02 marcocevoli

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

Karmalakas avatar Feb 14 '21 22:02 Karmalakas

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?

rhukster avatar Feb 18 '21 03:02 rhukster

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

Karmalakas avatar Jun 23 '21 17:06 Karmalakas

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>

splitbrain avatar Aug 25 '21 09:08 splitbrain

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

msa2020user avatar Aug 29 '23 14:08 msa2020user