Written by The Jahia Team
 
Marketers
Sysadmins
   Estimated reading time:
7.2.3.4 7.3.0.2

My website does not have a sitemap and I need to generate it: how can it be done?
 

Answer

To generate a sitemapn the module Jahia sitemap is the one to use. Unfortunately as it was not added when the website was created, you have to follow these following steps:

  • Install the module sitemap and associate it to your website
  • Go the JCR Console (DX_URL/modules/tools/jcrConsole.jsp) and execute the following script
    def siteName = "SITE_NAME";
    def ni = session.getWorkspace().getQueryManager().createQuery("select * from [jnt:page] where ['jcr:mixinTypes'] <> 'jmix:sitemap' and ISDESCENDANTNODE('/sites/" + siteName + "')", Query.JCR_SQL2).execute().getNodes(); 
    while (ni.hasNext()) {
     def n = ni.nextNode();
     n.addMixin("jmix:sitemap");
     log.info("Added mixin for : " + n.getPath()); 
    } 
    session.save();
    
    • This script will add the mixin jmix:sitemap which is being used to generate the sitemap
  • From the edit mode, publish all of your website in order to apply the previous modifications to the live workspace
  • Open the URL WEBSITE_URL/sitemap.xml