Generates XML sitemaps for search engine discovery.
Produces a standard sitemap.xml with <urlset>, <url>, <loc>,
and optional <lastmod> elements.
Examples
urls = [%{loc: "/articles/hello/", lastmod: ~D[2024-01-15]}, %{loc: "/about/", lastmod: nil}]
config = %{base_url: "https://example.com"}
xml = Sayfa.Sitemap.generate(urls, config)
Summary
Functions
Generates a sitemap XML string.
Functions
Generates a sitemap XML string.
Takes a list of URL maps and site config. Each URL map should have:
:loc— the path (e.g.,"/articles/hello/"):lastmod— aDateornil
Examples
iex> urls = [%{loc: "/articles/hello/", lastmod: ~D[2024-01-15]}, %{loc: "/about/", lastmod: nil}]
iex> config = %{base_url: "https://example.com"}
iex> xml = Sayfa.Sitemap.generate(urls, config)
iex> xml =~ "https://example.com/articles/hello/"
true
iex> xml =~ "<lastmod>2024-01-15</lastmod>"
true
iex> xml =~ "https://example.com/about/"
true