Controller for serving XML sitemaps with XSL styling.
Provides public endpoints for sitemap access:
- GET /{prefix}/sitemap.xml - XML sitemap with XSL stylesheet reference
- GET /{prefix}/sitemap.xml?format=html - Server-rendered HTML (for iframe previews)
- GET /{prefix}/sitemap.html - Redirects to sitemap.xml (deprecated)
- GET /{prefix}/sitemap-{n}.xml - Sitemap index parts (for large sites)
- GET /{prefix}/assets/sitemap-{style}.xsl - XSL stylesheets
Architecture: File-Only Storage
Sitemaps are stored in priv/static/sitemap.xml for:
- Direct nginx/CDN serving (bypasses Phoenix entirely)
- ETag from file mtime (always reflects actual content)
- On-demand generation (first request generates if missing)
How It Works
The XML sitemap includes an XSL stylesheet reference. When opened in a browser, the browser applies the XSL transformation client-side, rendering a beautiful HTML page. Search engine bots ignore the XSL and read the raw XML.
For iframe previews (admin panel), use ?format=html to get server-rendered HTML,
since iframes cannot apply XSL transformations.
XSL Styles
Available styles (configurable in settings):
- table - Clean table layout (default)
- cards - Cards grouped by category
- minimal - Simple list of links
Summary
Functions
Redirects to XML sitemap (deprecated).
Serves sitemap index part files for large sitemaps.
Returns current sitemap style and version for live-reload.
Serves the XML sitemap with XSL stylesheet reference.
Serves XSL stylesheet files for sitemap display.
Functions
Redirects to XML sitemap (deprecated).
HTML sitemap is now served by opening sitemap.xml - browsers apply XSL styling. This endpoint is kept for backward compatibility.
Serves sitemap index part files for large sitemaps.
URL format: /sitemap-{index}.xml where index is 1-based. Returns 404 if the index doesn't exist.
Returns current sitemap style and version for live-reload.
Used by JavaScript in XSL templates to detect style changes.
Serves the XML sitemap with XSL stylesheet reference.
Query parameters:
style- Override XSL style (table, cards, minimal)format=html- Force server-side HTML rendering (for iframe previews)
Returns 404 if sitemap module is disabled. Generates on first request if file doesn't exist.
Serves XSL stylesheet files for sitemap display.
Available styles: table, cards, minimal Default style (when accessed via /sitemap.xsl): table