I had to customize sitemap.xml for my concrete5 to suit my needs. You might find it useful I hope.

So, the first problem is that change frequency for all pages defaults to ‘monthly’. There are 2 ways to solve this problem:

If you want to change ‘monthly’ to another value (for example, ‘weekly’) for all pages, the best solution is to simply hardcode ‘concrete/jobs/generate_sitemap.php’:


if ($changefreq == '') {
$changefreq = 'monthly';
}

Change the variable to whatever you like: ‘yearly’, ‘monthly’, ‘weekly’, ‘daily’ or ‘hourly’. Of course it’s better to use the real change frequency.

If you want to have the ability specifying custom change frequency page-by-page, you should create page attribute: ‘sitemap_changefreq’

Go to c5 Dashboard, then open ‘Page Types’ and click ‘Add attribute’ button :

Handle – sitemap_changefreq
Type – Select menu
Searchable? – No
Name – Sitemap.xml change frequency
Values (one by line):
always
hourly
daily
weekly
monthly
yearly
never

When ready, click ‘Add’. Now you can open ‘Properties’ for a page, select ‘Sitemap.xml change frequency’ in ‘Custom fields’ dropdown and set desired change frequency.

The same with priority field. Here is the code in ‘concrete/jobs/generate_sitemap.php’:


if ($priority == '') {
$priority = '0.5';
}

The handle of the custom page attribute should be sitemap_priority. You can leave the field as text or select dropdown with some predefined set of values (for example, I’ve added select with values 0.0,0.1,…,1.0)

The next problem I faced with is that by default concrete 5 cms adds some pages to sitemap that I don’t like to be present there. Such as:

/download_file
/login
/index.php?cID=1 (duplicate of /)

I’ve added the following code in ‘generate_sitemap.php’:


$exclude_urls = array(
'http://www.mydomain.com/index.php?cID=1',
'http://www.mydomain.com/login',
'http://www.mydomain.com/download_file'
);
if (in_array($cPath,$exclude_urls))
continue;

Just before


if ($changefreq == '') {
$changefreq = 'monthly';
}

Finally, my sitemap.xml seems to look exactly like I want it.

P.S. If anybody doesn’t know how to generate sitemap.xml with concrete5: Go to Dashboard, then to Maintenance, and click Run checked (make sure appropriate task is selected)