BoxLang 🚀 A New JVM Dynamic Language Learn More...

Preside Extension: XML Sitemap

v1.2.4+0000015 Preside Extensions

Preside Extension: XML Sitemap Extension

An extension for Preside that will create sitemap.xml for all active pages.

Installation

From the root of your application, type the following command:

box install preside-ext-sitemap

.gitignore

The sitemap file will be generated by the scheduled task in your webroot. You should add the following pattern to your .gitignore file to keep it out of your repository:

/sitemap*.xml

Making your sitemap available to Google

There are two different ways to make your sitemap available to Google:

OR

  • Insert the following line anywhere in your robots.txt file, specifying the path to your sitemap:

    Sitemap: http://mydomain.com/sitemap.xml

Adding custom pages to your sitemap

By default, the extension will add all the active pages from your sitetree to the sitemap.

It may be that you have some custom, dynamically generated pages which you also wish to add (for example, news pages stored in a separate Preside object). There is an interception point, postPrepareXmlSitemapPages, which is called before the pages get built as an XML sitemap file. Available interceptData is pages (the array of sitemap pages already prepared) and siteId.

You can use whatever logic you want in your interceptor to gather pages to append to the array. Each array item is a struct containing the following keys:

  • loc (required) - the complete URL of the page
  • lastmod (required) - the date the content was last modified
  • priority (optional) - the priority of the page; one of important, high, normal, low. Defaults to normal
  • changeFreq (optional) - how often you expect the content to change; one of always, hourly, daily, weekly, monthly, yearly, never. Defaults to always

Multiple sites

The extension handles multiple sites out of the box. As noted above, the postPrepareXmlSitemapPages interceptor receives the siteId of the current site, for you to handle however you like.

In your Preside site settings page, there is a Sitemap tab. On here you will find a couple of options.

By choosing Exclude from sitemap, the site will be skipped completely when generating sitemaps.

You may also set a Sitemap suffix which is used to create the sitempa's filename. This is advisable when working with multiple sites, as each site will have its own sitemap. For instance, if you set a value of subsite here, the site's sitemap will be saved to /sitemap-subsite.xml. If you leave this empty, the file will be saved to /sitemap.xml.

Changelog

v1.2.3

  • Include partially restricted pages in sitemap

v1.2.2

  • #13 - Announce interception point after writing to file

v1.2.1

  • Convert to github build system
  • Add German i18n translations

v1.2.0

  • Change build/publish process
  • Add 'postPrepareXmlSitemapPages' interception point to append custom pages to sitemap
  • Add support for multiple sites

v1.1.2

  • Add default value to sitemap_priority

v1.1.1

  • Add ability to set sitemap changefreq on individual pages

v1.1.0

  • Add ability to set sitemap priority on individual pages

v1.0.10

  • Increase schedule task timeout
  • Don't use cache for page query
  • Build XML text manually for improved readabilty
  • Don't add .html to URL if page is homepage
  • Clarify checkLivePage() logic, improve var-scoping
  • Code style formatting

v1.0.9

  • Use correct repo url in box.json

v1.0.8

  • Fixing up publishing process

v1.0.7

  • Boxifying the repo with automated publish

v1.0.6

  • Ensures repeated process is reduces to improve the speed

v1.0.5

  • couple of function name that was missed previously

v1.0.4

  • Amendment to function names
  • Add missing arguemnt type in rebuildSitemap function
  • Update backend service to improve performance when building sitemap

v1.0.3

  • Added instruction for submitting the sitemap / adding to robots.txt
  • Updated typo for "last" in variable "elemLastMod"
  • FIX for fileWrite throwing a java.io.IOException error can't write down object of type [struct] to resource - always ensure the outut is a string / simple value
  • Add logger key exists checker before logging info and error message
  • Add logger info when sitemap task is being run

v1.0.1

  • Add README.md
  • Initial import of extension from Nelson's work

$ box install preside-ext-sitemap

No collaborators yet.
   
  • {{ getFullDate("2017-07-09T05:47:42Z") }}
  • {{ getFullDate("2024-10-15T11:47:50Z") }}
  • 3,421
  • 113,337