From 5c11de8399f5a5e38d5d2c9abb784411a7273125 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sun, 3 Dec 2017 04:00:05 +0100 Subject: [PATCH] add sitemap.xml --- site/robots.txt | 1 + src/Main.hs | 18 ++++++++++++++++++ templates/sitemap.xml | 11 +++++++++++ 3 files changed, 30 insertions(+) create mode 100644 templates/sitemap.xml diff --git a/site/robots.txt b/site/robots.txt index a0dde31..d659eed 100644 --- a/site/robots.txt +++ b/site/robots.txt @@ -1,3 +1,4 @@ User-agent: * +Sitemap: https://nek0.eu/sitemap.xml Disallow: /imprint.html Disallow: /contact.html diff --git a/src/Main.hs b/src/Main.hs index 2d100f3..9d66f9c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -138,6 +138,24 @@ main = >>= fmap (take 10) . recentFirst >>= renderRss feedConf feedCtx + create ["sitemap.xml"] $ do + route idRoute + compile $ do + rposts <- loadAll "site/**/*.md" + rsites <- loadAll "site/*.md" + -- rtxts <- loadAll "site/*.txt" + -- rascs <- loadAll "site/*.asc" + let sites = return (rposts ++ rsites) + let sitemapCtx = mconcat + [ listField "entries" + (postCtx tags <> constField "host" "https://nek0.eu/") + sites + , constField "host" "https://nek0.eu/" + , defaultContext + ] + makeItem "" + >>= loadAndApplyTemplate "templates/sitemap.xml" sitemapCtx + -------------------------------------------------------------------------------- sortIdentifiersByDate :: [Identifier] -> [Identifier] diff --git a/templates/sitemap.xml b/templates/sitemap.xml new file mode 100644 index 0000000..521bf77 --- /dev/null +++ b/templates/sitemap.xml @@ -0,0 +1,11 @@ + + +$for(entries)$ + + $host$$url$ + monthly + $if(lastmod)$$lastmod$$endif$ + 0.8 + +$endfor$ +