BoxLang 🚀 A New JVM Dynamic Language Learn More...
An extension for Preside that will create sitemap.xml
for all active pages.
From the root of your application, type the following command:
box install preside-ext-sitemap
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
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
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 pagelastmod
(required) - the date the content was last modifiedpriority
(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
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
.
java.io.IOException
error can't write down object of type [struct] to resource
- always ensure the outut is a string / simple value
$
box install preside-ext-sitemap