Automatic Sitemap Generator for WHMCS Pages and Articles
Introduction
The sitemap is an XML file where every URL of a website is listed. Search engines like Google, Bing and Yahoo use them for URL discovery so their spiders can cawl the site more intelligently and faster. Moreover they use it understand when a page has been updated with new content and when a new one has been published.
Simply put, without a sitemap you're just waiting for search engines to find your pages hoping that they do it in a reasonable amount of time. On the other hand with the sitemap you're telling them exactly where you are and what they need to look at. Mercury automatically generates a sitemap for news, blog posts, lab entries and articles of documentation.
Implementation
As we previously said, Mercury generates the sitemap and updates it on a daily basis with WHMCS cron job. Only published articles are included in the sitemap (draft, pending and cancelled articles are ignored). The resulting file is always stored in the following location (don't move it):{WHMCS_PATH}/modules/addons/Mercury/core/Mercury_Admin/resources/sitemap/sitemap.xml
If you can't see it, probably you've recently installed Mercury or you didn't publish any content yet. In the meantime you can start adding the sitemap to your robots.txt file that must be placed in the root of your site. At the very end of the file add the following string:Sitemap: {WHMCS_PATH}/modules/addons/Mercury/core/Mercury_Admin/resources/sitemap/sitemap.xml
Don't forget to replace {WHMCS_PATH} with WHMCS URL (eg. https://katamaze.com). We suggest to submit the sitemap also via Google Search Console and Bing Webmaster Tools to speed up the indexing.
XML Structure
Mercury natively supports multilingual pages and stores lastmod parameter, when necessary, directly in the XML. More details about the structure of this file can seen from the screenshot below.
Aliases and multiple Domains
If like us you use multiple domains or aliases to provide multilingual contents (katamaze.com for english and katamaze.it for italian), you have to include them in the sitemap. We made this process as easy as possible. Locate and open this file with a text editor:{WHMCS_PATH}/modules/addons/Mercury/core/Mercury_Admin/resources/sitemap/dist.systemurl.json
The file contains an example of a json array that is structured like follows.
{
"italian" : "https://example.it",
"spanish" : "https://example.es"
}
The key is the language and the value the corresponding URL. Now in this same directory create a file named exactly systemurl.json and add as many key/value pairs you need to insert all language/domain combinations you have. We underline that the default language and URL of WHMCS should not be added here.
Static URL
Mercury automatically adds news, blog posts, lab entries and articles of documentation to sitemap day by day but you can also manually add static URLs. Locate and open this file with a text editor:{WHMCS_PATH}/modules/addons/Mercury/core/Mercury_Admin/resources/sitemap/dist.staticurl.json
Here you'll find an example that shows you how to list static URLs. Use the same structure to add such links creating a new file named exactly staticurl.json in the same directory. Don't forget that special characters like &, <, > etc. should be escaped with their equilavent HTML entities.
Comments (0)