We are currently evaluating different cookie consent solutions considering its price models and therefore we need to know the amount of "active" URLs in our Craft multisite installation.

Does Craft somewhere cache or save complete URLs which I could count?

(I'm not sure if it does but since Craft always makes sure that URLs are unique I have hope that it does.)

  • Without delving into the database, can't you just count how many URL-enabled elements you have, multiplied by the number of sites?
    – gioppe
    Commented Aug 30, 2021 at 8:31
  • With Commerce and its product variants, not all entries available in all languages and so on, this might be inaccurate. Commented Aug 31, 2021 at 6:02

1 Answer 1


You could have a look at Luke Peter's Sitemap solution. This is a script that generates your sitemap. You can modify it to fit your need and just output a list of URLs.

Generate an XML Sitemap in Craft CMS

{# Create an empty array for all published entries #}
{% set entry_list = [] %}

{# Create a URI exclusion list for entries you don't want in the sitemap #}
{% set exclusions = ["blog/unlisted-blog-post", "thank-you-page"] %}

{# Get all sections (singles, channels, and structures) #}
{% set sections = craft.app.sections.allSections %}

{# Loop through each section #}
{% for section in sections %}

  {# Get all entries of this section type, but only if they're published and have a URL #}
  {% set entries = craft.entries.sectionId(section.id).status("live").uri("not ''").all() %}

  {# Merge these entries into the main list #}
  {% set entry_list = entry_list|merge(entries) %}
{% endfor %}

  Loop through all published entries to create the sitemap markup.
  Skip any entries with a URI that appears in the exclusions list.
{% for entry in entry_list if entry.uri not in exclusions %}
  <li><a href="{{ entry.url }}">{{ entry.url }}</a></li>
{% endfor %}

Most SEO Plugins that generate a Sitemap might solve this problem as well.

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.