SEO and Sitemaps

Updated 2025-10-31: AjaxCMS now includes automatic XML sitemap generation, robots.txt, and server-side rendering for search engines!

Automatic Sitemap Generation

The Node.js server now automatically generates XML sitemaps at /sitemap.xml for every site. No configuration needed!

Features:

Access your sitemap:

http://yoursite.com/sitemap.xml

Example sitemap entry:

<url>
  <loc>http://yoursite.com/?page=pages/menus/00-Home.md</loc>
  <xhtml:link rel="alternate" hreflang="en"
              href="http://yoursite.com/static/pages/menus/00-Home.md" />
  <lastmod>2025-10-31T12:00:00.000Z</lastmod>
  <changefreq>weekly</changefreq>
  <priority>0.8</priority>
</url>

Automatic robots.txt

Every site also gets a robots.txt file at /robots.txt:

User-agent: *
Allow: /

Sitemap: http://yoursite.com/sitemap.xml

Static HTML for Search Engines

AjaxCMS now provides server-rendered static HTML versions of all pages at /static/* routes:

http://yoursite.com/static/pages/menus/00-Home.md

These pages include:

Dual Rendering Strategy:

Testing Your Sitemap

Test sitemap generation:

curl http://yoursite.com/sitemap.xml

Test static rendering:

curl http://yoursite.com/static/pages/menus/00-Home.md

Validate sitemap structure:

# Check for proper XML format
curl -s http://yoursite.com/sitemap.xml | grep -o "<url>" | wc -l

# Check for alternate links
curl -s http://yoursite.com/sitemap.xml | grep "xhtml:link"

Test robots.txt:

curl http://yoursite.com/robots.txt

Search Engine Submission

Google Search Console:

  1. Go to Google Search Console
  2. Add your property
  3. Verify ownership
  4. Submit sitemap: http://yoursite.com/sitemap.xml

Bing Webmaster Tools:

  1. Go to Bing Webmaster Tools
  2. Add your site
  3. Verify ownership
  4. Submit sitemap: http://yoursite.com/sitemap.xml

Search Engine Considerations

Single-page applications (SPAs) like AjaxCMS require special consideration for SEO:

Modern search engines (Google, Bing) execute JavaScript and can index AJAX-loaded content, but the static HTML versions ensure complete and reliable indexing.

For more details, see the SEO Enhancements blog post.

Google Analytics Integration

AjaxCMS includes built-in support for Google Analytics with proper single-page application (SPA) tracking. Since pages load via AJAX without full refreshes, we need to manually track page views.

How It Works

The Google Analytics tracking code is in index.html, and the pageview tracking has been moved to trigger after each page load in js/ajaxcms.js:

// Step 8: Track page view in Google Analytics (if initialized)
if (typeof ga === 'function') {
    ga('send', 'pageview', location.href);
}

This ensures every AJAX page navigation is tracked as a separate pageview, giving you accurate analytics data.

Setup

  1. Get your tracking ID: Sign up for Google Analytics and create a property
  2. Configure in index.html: At the top of your index.html file, find the ajaxcms_google_analytics variable:
    <script>
    var ajaxcms_google_analytics = 'UA-XXXXXXXX-X'; // Replace with your ID
    var ajaxcms_splash_time = 5000;
    var default_background = 'network';
    </script>
    
  3. Set to empty to disable: var ajaxcms_google_analytics = '';

Privacy Note

Consider adding a cookie consent banner if you're serving users in the EU (GDPR compliance) or California (CCPA). There are many lightweight cookie consent libraries available via npm or CDN.