Setting Up an Auto-Generating Sitemap.xml

104 views
Skip to first unread message

Matt Reiner

unread,
Oct 6, 2016, 10:09:07 AM10/6/16
to Scroll Viewport Developers

I've rolled out our new documentation site at help.nimbleams.com and I'm trying to set up an auto-generating sitemap.xml file to which I can point Google Webmaster tools.


I'm following this K15t recipe which does not seem to be working for me. Any help anyone can offer would be appreciated.

I've created the sitemap.xml.vm file in my theme (I'm hoping I put it in the right place, the recipe is not specific):


I've created a new page titled "sitemap.xml":

And placed it in the root of my space (again, the recipe isn't too specific):


With that done, my Confluence page has not XML, when compared to K15t's own page:


Help.k15t.com:


Matt Reiner

unread,
Oct 6, 2016, 10:13:34 AM10/6/16
to Scroll Viewport Developers
In addition I'm unclear whether this recipie should be creating a static sitemap.xml file whenever I publish content to the space, or whether I should be able to configure Nginx to serve requests from sitemap.xml to sitemap.xml.vm.

Maximilian Hilbert (K15t Software)

unread,
Oct 11, 2016, 6:06:12 AM10/11/16
to Scroll Viewport Developers
Hi Matt,

The recipe you linked to describes a workaround for something that Scroll Viewport does not yet support natively. We have an improvement request for this in our issue tracking system: https://k15t.jira.com/browse/VPRT-824. You can watch this issue or vote on it if you like.

Having a reverse proxy serve a sitemap.xml file is another workaround that is unrelated to the approach with the sitemap.xml page and the sitemap.xml.vm template file.

The workaround with the sitemap.xml page only works if you use Scroll Viewport with hierarchical URLs. The page "sitemap.xml" has to be a direct child of your home page, so that its viewport-relative URL is simply "sitemap.xml" (note that you have to set the advanced plugin setting "slugs" to "classic" or the URL will be "sitemap-xml"; you can configure these settings at "<confluence-base-url>/plugins/servlet/scroll-settings/"; depending on your needs, you may or may not care about the name of the sitemap file in the URL). The template "sitemap.xml.vm" can be located anywhere in your theme or in fact have any name ending in ".vm". You just have to make sure that you provide the correct path in the page property on the sitemap.xml page. So if your template is at "/my-templates/my-sitemap.vm" in your theme, the template property on the sitemap.xml page has to contain that value. In addition you need some sort of dispatching mechanism in your page.vm that calls the template if the page property "template" is present.

Example page.vm:
#if ($page.properties.template) 
     $include.template($page.properties.template) 
#else 
    <!-- normal page.vm code -->
#end

This code is very generic and allows you to provide custom templates for other pages if you add the page property "template". Instead you could of course also check if the current page is titled "sitemap.xml" and then dispatch to your sitemap.xml.vm template. In that case you wouldn't need the page property.

In this setup the sitemap is generated on the fly whenever someone requests the page.

I hope this made things a bit clearer.

Best regards,
Maximilian

Matt Reiner

unread,
Oct 11, 2016, 12:26:26 PM10/11/16
to Scroll Viewport Developers
Hey Maximilian,

Thanks for clarifying. As it turns out, we are using flat URLs, so this work around will not work for us. I'll be sure to watch the linked improvement however, and hope for the best.

Thanks,
Matt
Reply all
Reply to author
Forward
0 new messages