Hi all - newbie alert!
I’ve used OctoberCMS in the past but veered off to another provider for a while. I’m trying it out again and am stuck with the new setup for building a sitemap.
I have copied the standard sitemap.yaml and sitemap.htm as per this article, but how do I create entries in the backend? It looks similar to before but now I have to add a page title and reference to the relevant page?
If this is right, when I’ve done it for a few pages, my sitemap.xml file isn’t showing anything just the standard urlset text as per the sitemap.htm code.
Is anyone able to point me in the right direction as I can’t find a user guide for how to use it anywhere.
Thanks
Pete
EDIT So after comparing the demo theme sitemap.htm file to the one I created, I spotted [collection] was different. I replaced it with the demo version - [collection sitemap] and now I can see the entries on my sitemap. Phew… maybe helpful to someone to see this.
1 Like
Hi and welcome @prewebdesign
I’m glad you got it solved, the demo theme does get updated with every minor release with improvements.
1 Like
Thanks @daftspunk - I have emailed hello@ too about some other questions I had re. moving forward with October.
Just a follow up on this - is there a way to export sitemap definitions from one database to another? I have migrated from Winter back to October on a client site and owing to hundreds of pages in the sitemap, I wondered if there was an easy way to transfer it without adding them one by one to the new sitemap?
Yes, you can with some code:
Based on these blueprints
Here is a light example:
// Step 1: look at what you've got
$sitemap = \RainLab\Sitemap\Models\Definition::all();
foreach ($sitemap->items as $item) {
// Inspect each item
trace_log($item);
}
// Step 2: Create a new sitemap
$newSitemap = \Tailor\Models\EntryRecord::inSection('Site\Menus');
$newSitemap->title = 'Sitemap';
$newSitemap->slug = 'sitemap';
$newSitemap->save();
// Step 3: Add items
\Tailor\Models\EntryRecord::inSection('Site\Menus')->where('slug', 'sitemap')->first();
foreach ($sitemap->items as $item) {
$newItem = $newSitemap->items()->make();
$newItem->title = $item->code;
$newItem->reference = 'october://cms-page@link/index?title=Demonstration';
$newItem->save();
}