I have installed sitmap module to create sitemap.xml file.
Now I want to add some custom element like


for some URLS.

2 Answers 2


If you don't mind a programmatic approach, then follow these steps:

  1. Ensure that XML Sitemap module is installed & enabled
  2. Create/use a custom module (say, MYMODULE) & use the following hook:

      function MYMODULE_xmlsitemap_element_alter(&$element, $link, $sitemap) { 
        // Some logic to generate datetime
        // or hardcoded value
        $element['expires'] = '2010-10-10';
  3. Go to admin/config/search/xmlsitemap/batch-generate & click on 'Run'
  4. Go to admin/config/search/xmlsitemap/rebuild & click on 'Rebuild sitemap'
  5. Go to sitemap.xml, inspect element or view page source & verify that 'expires' tag is included

Hope this helps.


The expires tag is not valid Sitemaps.org Protocol - http://www.sitemaps.org/protocol.html

You can configure the overall sitemap lifetime on this page: /admin/config/search/xmlsitemap/settings

Set it the Minimum sitemap lifetime to "1 Day" and make sure your nodes are unpublished when you want them to expire, either manually or using a module like Scheduler, and they will be removed from the sitemap.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.