Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing mechanism to create apphook specific sitemap #6680

moellering opened this issue May 8, 2019 · 2 comments


None yet
2 participants
Copy link

commented May 8, 2019


When creating an app that is included on djangocms via apphooks at multiple places I don't see a way on how to provide a proper sitemap.

Expected behaviour

I should be able to provide a function for elements that provides a custom sitemap.

I image something in the likes of the following

class MyApphook(CMSApp):
    name = "MyApphook"
    app_name = "myapphook"
    def get_urls(self, page=None, language=None, **kwargs):
        return ["myapphook.urls"]
    def get_sitemap(self, page=None, language=None, **kwargs):
        return MyApphookSitemap(page, language)
class MyApphookSitemap(CMSApp):
    def __init__(self, page, *args, **kwargs):
         super().__init__(*args,**kwargs) = page
    changefreq = "monthly"
    priority = 0.5
    def items(self):
        return somehow_generate_the_entries()
    def location(self, obj):
        return somehow_generate_the_location_for(obj)
    def lastmod(self, obj):
        return somehow_calculate_the_lastmod_for(obj)

Actual behaviour

The cms just creates an entry in the sitemap for the page that has the apphook.
a) The lastmod property does not reflect the content of the apphook, since it only checks for page properties
b) no sub pages of the apphook are included in the sitemap


  • Python version: 3.5.5
  • Django version: 2.1.7
  • django CMS version: 3.6.0

This comment has been minimized.

Copy link

commented May 13, 2019

You can do this in


from cms.sitemaps import CMSSitemap
from import NewsSitemap

 sitemaps = {
        'cmspages': CMSSitemap,
        'news': NewsSitemap
urlpatterns += [
    url(r'^sitemap.xml$', sitemap, {'sitemaps': sitemaps}),

This comment has been minimized.

Copy link

commented May 15, 2019

Hi Sacha,
thanks for your answer. Unfortunately that does not allow a developer of an application to modify the entry for the pages that are using the apphook.
Once I create a page, set an apphook and publish the page, its url and modfication date are added to the apphook by the CMSSitemap. The content provided by the apphook might change every day, the i would not be able to modify the lastmod property.

Furthermore, the NewsSitemap would have to check if the pages would be reversable. This could be a problem for an app where the respective apphook is not yet assigned to a page.

Summing up: One would be able to generate a sitemap using the current mechanisms, but:
a) One has to use workarounds to update the lasmod property of pages with apphooks.
b) App Specific Sitemaps would have to search around which pages are using the respective apphooks or if the links are reversible.

I'm currently using my own Subclass of CMSSitemap to solve those problems which works fine for me, but maybe others might have a similar use case and may profit from a proper apphook centered interface here. Before creating a pull request, I'd like to hear your thoughts.

Edit: And in addition to that, I can't even control if the page containing the apphook appears in the sitemap or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.