Skip to content

Commit 0656c67

Browse files
committed
add robots & sitemap generation
1 parent 6a405f4 commit 0656c67

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ jobs:
3636
- name: Build
3737
run: mdbook build
3838

39+
- name: Generate sitemap.xml
40+
shell: bash
41+
run: |
42+
set -euo pipefail
43+
BOOK_DIR="book"
44+
BASE_URL="${{ steps.pages.outputs.base_url }}"
45+
BASE_URL="${BASE_URL%/}"
46+
OUT="$BOOK_DIR/sitemap.xml"
47+
48+
{
49+
echo '<?xml version="1.0" encoding="UTF-8"?>'
50+
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
51+
} > "$OUT"
52+
53+
find "$BOOK_DIR" -name "*.html" \
54+
| sed "s|^$BOOK_DIR||" \
55+
| sed 's|/index.html$|/|' \
56+
| sed 's|\.html$||' \
57+
| sort -u \
58+
| while read -r path; do
59+
printf ' <url><loc>%s</loc></url>\n' "$BASE_URL$path" >> "$OUT"
60+
done
61+
62+
echo '</urlset>' >> "$OUT"
63+
3964
- name: Upload artifact
4065
uses: actions/upload-pages-artifact@v3
4166
with:

src/robots.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
User-agent: *
2+
Allow: /
3+
4+
Sitemap: https://cloudexit.escapecloud.io/sitemap.xml

0 commit comments

Comments
 (0)