XML Sitemaps

Automatically generates and serves XML sitemaps for your Phoenix application with proper routing and controller setup. The feature includes robots.txt integration and follows XML sitemap protocol standards for optimal search engine discovery.

Key Benefits

  • Zero-configuration SEO foundation - Automatically serves sitemaps at /sitemap.xml with proper XML content-type headers
  • Test coverage included - Complete controller tests ensure sitemap reliability across deployments
  • Standards compliant - Follows sitemaps.org protocol with proper XML structure and robot.txt integration
  • Phoenix-native implementation - Uses standard Phoenix controllers and templates, no external dependencies

Implementation Details Creates a dedicated SitemapController with XML template rendering through the :xml format in your Phoenix router. The implementation includes a SitemapXML view module using embed_templates for XML generation, with proper content-type handling and layout bypassing for raw XML output.

Usage Example

# Automatically available at /sitemap.xml
# Template renders with Phoenix URL helpers
<url>
  <loc><%= url(~p"/") %></loc>
  <changefreq>daily</changefreq>
  <priority>1</priority>
</url>

Configuration Update the robots.txt domain from example.com to your production domain. Extend the XML template by adding more <url> entries for additional routes or dynamic content from your database.