I have a website with which has some different URLs that are not inserted in the url_alias table not embedded into Drupal content system, but they are generated on-the-fly by custom PHP logic inside a module.

How can I alter the sitemap generated by XMLSitemap modules in order to include these generated "artificial" URLs?

For example:

www.example.com/products is a content node.

When accessing


I see the list of the products under category1 and subcategory 2, but generated on the fly by custom code, from data from other repository different to Drupal's one.



is not in the database table: url_alias and it does not pertain to a different node to the first one (whithout parameters), either: the screen displays different info based only on the custom module.

I would like to know how to include this URL in a automated way in the xml sitemap.

  • 1
    You need to implement hook_xmlsitemap_index_links(), and use the xmlsitemap_link_save() function. The easiest thing to do is to look at the existing implementations for node and menus. I'll see if I can dig up a generic example for you. – mpdonadio Jan 25 '16 at 16:59
  • I have looked the API info, and the problem is that the data model seems to need the node->id or the entity_id, so I would have a problem for not having the "external" products mapped to Drupal nodes. I could use a partial Feeds import, but would be great if I could just insert a link (not the object, but a link string) in the output stream in the last moment. I would thank you the example, but as I say, I cannot see that my data model fits the API requeriments. – Cesar Jan 25 '16 at 17:44
  • You can map arbitrary data (out of the box, the module support custom links). The last time I did this was about two three years ago, so I just need to dust off the cobwebs to give you an example. – mpdonadio Jan 25 '16 at 17:52
  • Ok, I will appreciate very much. – Cesar Jan 25 '16 at 18:05
  • Any updates on this? – Codium Feb 21 '18 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.