File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ Sitemap: https://errors.haskell.org/sitemap.xml
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ main = hakyll $ do
34
34
route idRoute
35
35
compile copyFileCompiler
36
36
37
+ -- Necessary to point webcrawlers to the correct sitemap
38
+ match " robots.txt" $ do
39
+ route idRoute
40
+ compile copyFileCompiler
41
+
37
42
match " images/*" $ do
38
43
route idRoute
39
44
compile copyFileCompiler
@@ -131,6 +136,27 @@ main = hakyll $ do
131
136
132
137
match " templates/*" $ compile templateBodyCompiler
133
138
139
+ create [" sitemap.xml" ] $ do
140
+ route idRoute
141
+ compile $ do
142
+ let messages = loadAll " messages/*/*"
143
+ let host = " https://errors.haskell.org"
144
+ let pageCtx :: Context String
145
+ pageCtx =
146
+ mconcat
147
+ [ modificationTimeField " lastmod" " %Y-%m-%d" ,
148
+ constField " host" host,
149
+ defaultContext
150
+ ]
151
+ let sitemapCtx =
152
+ mconcat
153
+ [ listField " entries" pageCtx messages,
154
+ constField " host" host,
155
+ defaultContext
156
+ ]
157
+ makeItem " "
158
+ >>= loadAndApplyTemplate " templates/sitemap.xml" sitemapCtx
159
+
134
160
create [" api/errors.json" ] $ do
135
161
route idRoute
136
162
compile $ do
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <urlset xmlns =" http://www.sitemaps.org/schemas/sitemap/0.9" >
3
+ $for(entries)$
4
+ <url >
5
+ <loc >$host$$url$</loc >
6
+ <changefreq >weekly</changefreq >
7
+ $if(lastmod)$<lastmod >$lastmod$</lastmod >$endif$
8
+ <priority >0.8</priority >
9
+ </url >
10
+ $endfor$
11
+ </urlset >
You can’t perform that action at this time.
0 commit comments