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:
- Automatically discovers all
.htmland.mdfiles inpages/directory - Includes both AJAX and static HTML versions via alternate links
- Provides last modification timestamps
- Organized sections: Homepage, Menu Pages, Blog Posts, Other Pages
- Human-readable display with XSLT stylesheet
- Generated fresh on every request
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:
- SEO-optimized meta tags
- Open Graph tags for social media
- Twitter Card tags
- Canonical URLs pointing to AJAX version
- Clean HTML without JavaScript dependencies
Dual Rendering Strategy:
- AJAX version (
/?page=...) - Full interactive experience for users - Static version (
/static/...) - Crawlable HTML for search engines
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:
- Go to Google Search Console
- Add your property
- Verify ownership
- Submit sitemap:
http://yoursite.com/sitemap.xml
Bing Webmaster Tools:
- Go to Bing Webmaster Tools
- Add your site
- Verify ownership
- Submit sitemap:
http://yoursite.com/sitemap.xml
Search Engine Considerations
Single-page applications (SPAs) like AjaxCMS require special consideration for SEO:
- URL Structure: AjaxCMS uses
?page=query parameters, which search engines can index - Static Alternatives: Every page has a static HTML version for crawlers
- Meta Tags: Static pages include proper
<title>, description, and Open Graph tags - History API: Browser history is properly managed for back/forward navigation
- Content Accessibility: All content is accessible via direct URLs
- Sitemap: Automatic XML sitemap helps search engines discover all pages
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
- Get your tracking ID: Sign up for Google Analytics and create a property
- Configure in index.html: At the top of your
index.htmlfile, find theajaxcms_google_analyticsvariable:<script> var ajaxcms_google_analytics = 'UA-XXXXXXXX-X'; // Replace with your ID var ajaxcms_splash_time = 5000; var default_background = 'network'; </script> - 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.