Drupal 9 SEO: Simple XML Sitemap module

02 Oct 2015

The Simple XML Sitemap module was originally created by gbyte as a temporary replacement for the non-functioning Drupal 8 XML Sitemamp Module. After putting some more work into it however, we decided to keep using it in our D8 & D9 projects, as it is very lightweight, simple to use and most importandly, adheres to a newer XML sitemap standard.

The 2.x branch features most of the functionality of the heavier XML Sitemap module while also featuring hreflang and image XML sitemaps, which is a new Google standard for creating multilingual XML sitemaps that should improve SEO even more.

The 3.x branch adds a robust generation process that works with huge sites in limited environments. It also introduces the concept of sitemap variants which are instances of different sitemap types which in turn are made of sitemap and URL generators. This makes it possible to run several different sitemap types on one Drupal instance.

The 4.x branch is a rewrite with developers/integrators in mind and makes much greater use of Drupal's entity API dropping some of its very specific chaining API. On top of that, it features many code and UI improvements.

Here is the description from the module page:

Every webpage needs an automatic XML sitemap generator for SEO reasons. Sitemaps generated by this module adhere to the new Google standard regarding multilingual content by creating hreflang sitemaps and image sitemaps - Googlebots will thank you later.

In addition to the default hreflang sitemaps, the module's API allows creating and publishing of custom sitemaps with arbitrary content.

Functionality

The module generates a multilingual sitemap for entities, views and custom links. Out of the box it supports most of Drupal's content entity types including:

  • nodes
  • taxonomy terms
  • menu links
  • users
  • ...

Contributed entity types like commerce products can be indexed as well. Various inclusion settings can be set for bundles and overridden on a per-entity basis. Sitemap generation can be altered through custom URL generator plugins and hooks. The sitemaps can be automatically submitted to search engines.

Here is a sample of the markup it generates (press ctrl+u to view the source).

8.x-3.x

Ability to create any type of sitemap via plugins

The 8.x-3.x release allows not only for customizing the URL generation through UrlGenerator plugins as 2.x does, but also creating multiple custom sitemap types through sitemapGenerator plugins and running all the sitemaps on the same Drupal instance. Now e.g a Google news sitemap can be added to a Drupal instance. This is possible through the new concept of sitemap variants.

Ability to create sitemap variants of various sitemap types via UI

Now e.g links form a specific entity bundle can be indexed in a specific sitemap variant with its own URL.

No more out of memory/time errors

The generation process has been streamlined to using a single queue regardless of whether batch generation is being used, or backend (cron/drush) processes. This should allow hundreds of thousands of entities/elements being indexed without memory errors.
If there is a problem, the generation process picks up from the last indexed element. The sitemap variants are only published after the generation has been completed.

Other

  • Automatic submission to search engines
  • Views and views arguments support
  • XSL stylesheets for human visitors
  • Performance test script included

4.x

Module rewrite with developers/integrators in mind

4.x makes much greater use of Drupal's entity API dropping some of its very specific chaining API. See #3219383: Roadmap for 4.x.

See this post for more details on the 4.x branch.

Should you use this over 3.x?

Yes. New features are only coming to 4.x.

Upgrade path

Please do not forget to run drush updb or update.php after every update. If you get an error, run core/rebuild.php before the above.

Keep in mind, the module APIs change between major releases.

  • Branch 8.x-1.x is no longer supported and there is no upgrade path.
  • You can upgrade from any 8.x-2.x version to 8.x-3.x or (preferably) to 4.x.

Other

Similar modules: XML Sitemap was the de facto XML sitemap generator prior to Drupal 8 and a stable version for D8 has just been released.

Feel free to grab the module from the module page.

If you are unsure whether to get simple_sitemap or xmlsitemap, check out this comparison on the two modules.

This article describes all the new features of the 4.x version.

All info about the project

Comments

Hello,

I just installed this module, but could not figure how to use it. Are there any documentation or how-to I can follow?

Thanks!

Hi John,

you can include content into the sitemap by adjusting the settings on the corresponding entity type edit pages (e.g. admin/structure/types/manage/[type] for content types and admin/structure/taxonomy/manage/[vocabulary] for taxonomy vocabulary pages).

There is also the possibility of adding custom links, however this requires exporting the simple_sitemap configuration, altering it and importing it back. I may add an UI for that in the future.

I'm confused. I navigated to each of my content types and enabled (checked) "Index content of this type." I then navigated to "Configuration > Simple XML Sitemap Settings" and pressed the "Regenerate Content" button and -- after processing the request -- Simple XML Sitemap reported " The XML sitemap has been regenerated for all languages." I then loaded MyDomain.com/sitemap.xml which resulted in this...

MyDomain.com/
1.0

Where is the mapping to all of my content?

In addition, there does not appear to be any sitemap.xml file located in my site's root directory (when I look with my FTP client).

What am I doing wrong?

Hello,

I installed this module and i configured. but i want add a menu in footer "sitemap". when click on sitemap it will display all links in that page. what is the path to add as menu item ?

Thanks,
Ramesh S

Hi Ramesh,

the path to the sitemap is /sitemap.xml and putting it into a menu would work.

However, this is an XML sitemap and usually not used by people - it is used by search engines for indexing all pages of your website (SEO).

What you are probably after is a traditional sitemap, check out this module: https://www.drupal.org/project/sitemap

After installing the module and doing all the necessary configs, I got the below error, anyone please assist.

An error has occurred. This may result in an incomplete XML sitemap.
Please continue to the error page

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /batch?id=34&op=do_nojs&op=do
StatusText: Internal Server Error
ResponseText: {}

Hi,

I just install your Drupal 8 module, configure it by adding a post type, and click the "Regenerate sitemap" .

The XML is updated, but i get an error on the admin page :

Warning: Illegal string offset 'path' in Drupal\simple_sitemap\SitemapGenerator->getCustomUrlsData() (line 102 of modules/simple_sitemap/src/SitemapGenerator.php).
Drupal\simple_sitemap\SitemapGenerator->getCustomUrlsData() (Line: 84)
Drupal\simple_sitemap\SitemapGenerator->startGeneration() (Line: 538)
Drupal\simple_sitemap\Simplesitemap->generateSitemap() (Line: 120)
Drupal\simple_sitemap\Form\SimplesitemapSettingsForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('simple_sitemap_settings_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 139)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Can you help me ? Is it a code error or a bad configuration ?

Thanks for your help and for your good job.

z2m

I forgot the more important, the configuration of the module

Im using Drupal 8.2.4, and the module have the default configuration :

Regenerate the sitemap on every cron run : checked
Exclude duplicate links : chacked
Skip non-existent translations : unckecked
Maximum links in a sitemap : 2000
Refresh batch every n links : 1500

Thanks

Hi,

The dev version works fine, no errors on the module admin page.

Thanks for all and your rapidity.

z2m

Unfortunately this module does not work with the Domains module at the time of this writing. Articles that are marked as "Send to All Affliates" will show in the sitemap, but that will have urls of different domains. If you remove the "Send to All Affliates" then NO pages will be in your sitemap. Ugg... also there's a caching issue for multiple domains that require you to override the caching logic.

Hi, I just install your Drupal 8 module, configure it by adding a post type, and click the "Regenerate sitemap" . The XML is updated, but i get an error on the admin page:

Warning: Illegal string offset 'path' in Drupal\simple_sitemap\SitemapGenerator->getCustomUrlsData() (line 102 of modules/simple_sitemap/src/SitemapGenerator.php).

Can you help me ? Is it a code error or a bad configuration?

I've connected this module on my Windows mechanism into drupal/sites/default/modules. I've stimulated all the submodules of XML sitemap in running menu. Per docs, I've also run cron.php physically to create sitemap.xml in drupal/sites/default/files - but it's just not present there level when next re-install. As concerned with seo company regulate that how can I might to generate sitemap.xml?

'modules' should be the right path inside the drupal folder.

Simple XML sitemap does not have submodules, you should be fine running the main module. Or do you mean xml_sitemap?

If you are referring to simple_sitemap, no physical sitemap.xml file is generated, instead xml data is written and read from the database. Check out the documentation, or use the issue queue to get support.

Sorry for my English. I added a watermark on the photo. But in the site map I see not a photo with a watermark, but a default photo without a sign. This is a problem for me.

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang target> <em> <strong> <cite> <blockquote cite> <pre> <ul type> <ol start type> <li> <dl> <dt> <dd> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Get a quote in 24 hours

Wether a huge commerce system, or a small business website, we will quote the project within 24h of you pressing the following button: Get quote