ACF Library

GenSiteMap

Back to List

Description: Generate sitemap XML for a site

FileMaker Prototype:

Set Variable [$res; ACF_Run("GenSiteMap")]

Category: WEB

Function source:

function GenSiteMap()
   string map;
   array string htmlpath; 
   array timestamp modifiedTS;
// Query the documents table....   
   string res = ExecuteSQL ( "SELECT slug_filename, ModificationTimestamp FROM ACF_Documents
   INTO :htmlpath, :modifiedTS"); 
   
   int i, d = sizeof (htmlpath ); 
   XML SiteMap; 
   string base = "https://horneks.no/manuals/ACF/"; 
   // loop the SQL result. 
   for ( i = 1, d )
      if ( file_exists ( Preferences::HTML_Folder + "/" + htmlpath[i])) then
         SiteMap["urlset.url[]"] = XML("loc", base + htmlpath[i], 
            "lastmod", string(modifiedTS[i], "%Y-%m-%d"), 
            "changefreq", "weekly");
      end if
   end for
   
   // Set the namespace attribute on the root-node. 
   XMLattributes (SiteMap["urlset"], XML("xmlns","http://www.sitemaps.org/schemas/sitemap/0.9")); 
   map += String(SiteMap); 
   
   // Save the sitemap.xml to the HTML folder. 
   string file = Preferences::HTML_Folder + "/sitemap.xml"; 
   int x = open ( file, "w"); 
   write (x, map); 
   close (x);
   return "OK"; 
end

The GenSiteMap function generates a sitemap to help Google index your documents effectively. It specifies the document locations, last modified dates, and the frequency of changes. The function retrieves the document list from a FileMaker table using an SQL query, then formats it according to Google’s specifications. The resulting file, named sitemap.xml, can be uploaded to your site and configured in Google Search Console for indexing.

Example

Set Variable [$res; ACF_Run("GenSiteMap")]

Resulting File: sitemap.xml

sitemap-xml

Additionally, a manually created sitemap index file, sitemap-index.xml, directs Google to the various sitemaps on the site.

sitemap-index.xml

site-index-xml

Back to List