Master sitemap with different sitemap

Created on 29 June 2023, over 1 year ago
Updated 5 April 2024, 8 months ago

Problem/Motivation

 We are managing the sites at Acquia Site Factory. For SEO purposes, we need the sitemap in the following structure: Variants are working fine, but I cannot map different sites XML to the master sitemap's XML. Please suggest the next step. Thank you.

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
       <loc>https://www.example.com/sitemap_content_de-at.xml</loc>
  </sitemap>
  <sitemap>
       <loc>https://www.example.com/sitemap_content_de-be.xml</loc>
  </sitemap>
  <sitemap>
       <loc>https://www.example.com/sitemap_content_de-ch.xml</loc>
  </sitemap>
  <sitemap>
      <loc>https://www.example.com/sitemap_content_de-de.xml</loc>
  </sitemap>
</sitemapindex>

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Fixed

Version

4.0

Component

Code

Created by

🇮🇳India Gnanagowthaman sankar Puducherry

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Gnanagowthaman sankar
  • Status changed to Postponed: needs info over 1 year ago
  • 🇩🇪Germany gbyte Berlin

    3.x is unsupported. Please use 4.x and let me know if what you are after can be achieved. If not, please be very specific as I am not sure what you mean with 'mapping xml'. If you mean having a sitemap index for all the sitemaps, this is already possible with 4.x.

  • 🇮🇳India Gnanagowthaman sankar Puducherry

    Hi @gbyte,

    First of all, I'm sorry for using the term mapping.xml.

    By upgrading the module to the 4.x version, I can achieve the above structure. Thank you so much. I have one more question. Let's assume www.example.com contains a sitemap.xml (www.example.com/sitemap.xml). By clicking that, it should open the following structure, which should bring different sitemaps into this parent www.example.com/sitemap.xml. Is it possible to achieve this, or do I require any hooks or additional plugins or any contrib module to achieve the following output? Please guide me. Thank you.

    <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
       <sitemap>
           <loc>https://www.test.com/sitemap.xml</loc>
      </sitemap>
      <sitemap>
           <loc>https://www.sample.com/sitemap.xml</loc>
      </sitemap>
      <sitemap>
           <loc>https://www.dummy.com/sitemap.xml</loc>
      </sitemap>
      <sitemap>
          <loc>https://www.random.com/sitemap.xml</loc>
      </sitemap>
    </sitemapindex>
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Gnanagowthaman sankar Puducherry

    Hi gbyte, could you please review the above one.

  • Status changed to Fixed 8 months ago
  • 🇩🇪Germany gbyte Berlin

    Sorry for the late answer, I missed this support request twice apparently. :(

    It's possible to have external links to sitemaps in a sitemap index type of sitemap. Here is how:

    • The simplest approach would be creating a new sitemap type via UI with "Sitemap index generator" as sitemap generator and "Arbitrary URL generator" as URL generator.
    • Then create a sitemap of this type.
    • Now implement hook_simple_sitemap_arbitrary_links_alter() and add the URLs programmatically. Example:
    function hook_simple_sitemap_arbitrary_links_alter(array &$arbitrary_links, SimpleSitemapInterface $sitemap) {
    
      // Add an arbitrary link to all sitemaps.
      $arbitrary_links[] = [
        'url' => 'https://some-arbitrary-link/',
        // An ISO8601 formatted date.
        'lastmod' => '2012-10-12T17:40:30+02:00',
      ];
    }
    

    There is of course also the cleaner way which is to implement a URL generator plugin yourself and using that instead of using the arbitrary link plugin. I hope this helps.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024