How can I make the sitemap update after a certain event?
Good afternoon, I’ve implemented a feature that allows me to automatically create and update the sitemap. I’ve attached the file below. Currently, it works in a simple way: it’s enough to place this file in the root directory of a website running on UNA CMS, and either set up a cron job or manually visit the URL: your-site/ sitemap.php periodically. This triggers the sitemap to update, adding the URLs of the relevant site pages. However, this approach isn’t ideal. I would like the sitemap to update automatically when, for example, someone adds, edits, or deletes a post or discussion. How can this be implemented?
-
- · Ivan Mishchenko
- ·
Ideally, of course, the best solution would be to create a proper customizable module. It should allow selecting which site pages to include in the sitemap, setting priorities, and splitting the sitemap into multiple parts. Nowadays, having a sitemap is more important than ever - with a large number of diverse pages, many important ones may never get indexed by search engines otherwise.
-
-
·
LeonidS
- ·
Hello @Ivan Mishchenko !
Yes, it will require the custom module which will "listen" new site events via the alerts system (approx. like the Timeline) and generate the actual site map. You current variant doesn't look safe.
-
·
LeonidS
-
By the way, yeah, I didn’t even think about security. But it’s more of a temporary solution - to create the map and then delete the file.