I'm trying to build and XML site map that sorts all entries by their modification dates with the newly modified first.

{% for entry in craft.entries.find() %} ignores the structures,

{% for entry in craft.entries.section().find() %} returns the same as above,

{% for entry in craft.entries.section('mainPages').find() %} returns the structure as expected.

Looking for a way to include everything in a single, sortable query.


Actually your code should work just fine. But by default only 100 entries are fetched, maybe you need to increase the limit:

{% set entries = craft.entries.section().limit(null) %}

But if you just want to create a Sitemap, try Ben Croker's Sitemap-Plugin (I really like it)


This should output what you want:

{% for entry in craft.entries.order('dateUpdated desc') %}
    {{ entry.title }}
{% endfor %}

Although the easiest way to create an xml sitemap is to use the Sitemap Plugin.

  • I needed to add elements in the above query for it to work (Craft 3). order('elements.dateUpdated desc')
    – Gareth
    Jul 28 '18 at 4:08

In addition to the $49 plugin mentioned in other answers, there's also a more basic one that is free: https://github.com/xodigital/SimpleSitemap

Your Answer

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

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