Skip to content

Commit d213b83

Browse files
authored
Merge pull request #324 from gonX/add-sitemap
Add XML sitemap
2 parents 31918d9 + df5dfdb commit d213b83

4 files changed

Lines changed: 54 additions & 13 deletions

File tree

.github/workflows/jekyll.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ jobs:
2020
- name: Run tests
2121
run: ./run-tests.sh || exit 1
2222

23-
internal-links:
24-
name: "Absolute Internal Links"
25-
needs: build
26-
runs-on: ubuntu-latest
27-
steps:
28-
- name: Checkout
29-
uses: actions/checkout@v4
30-
31-
- uses: ./.github/workflows/site-workflow
32-
33-
- name: Check for internal absolute links
34-
run: bash -c "! grep -REi 'https?://(www.)?opentabletdriver.net' site/_site || exit 1"
35-
3623
html-validation:
3724
name: "Validate HTML"
3825
needs: build

site/_layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<title>{{ site.title }}</title>
1010
{%- endif -%}
1111
{% include styles.html %}
12+
<link rel="canonical" href="{{ site.url }}{{ page.url | replace:'index.html',''}}">
1213
</head>
1314
<body>
1415
<header class="mb-4">

site/sitemap.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
layout:
3+
---
4+
5+
<?xml version="1.0" encoding="UTF-8"?>
6+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
7+
{%- for page in site.pages -%}
8+
{%- if page.url contains '.xml' or page.url contains 'assets' %}{%- else %}
9+
<url>
10+
<loc>{{ site.url }}{{ page.url }}</loc>
11+
</url>
12+
{%- endif -%}
13+
{% endfor %}
14+
{%- for page in site.sections -%}
15+
{%- if page.layout == "redirect" -%}{%- continue -%}{%- endif %}
16+
<url>
17+
<loc>{{ site.url }}{{ page.url | replace: 'index.html', '' }}</loc>
18+
</url>
19+
{%- endfor -%}
20+
{%- for page in site.wiki %}
21+
<url>
22+
<loc>{{ site.url }}{{ page.url | replace: 'index.html', '' }}</loc>
23+
</url>
24+
{%- endfor %}
25+
</urlset>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
#
3+
# usage:
4+
# ./$0 "jekyll root" "html root"
5+
#
6+
# for use in CI to ensure absolute links aren't being written to html files
7+
#
8+
set -e # exit on any error
9+
10+
if [[ -z "$1" ]]; then
11+
echo "Usage: $0 HTML_ROOT"
12+
exit 127
13+
fi
14+
15+
HTML_ROOT="$1"
16+
17+
! grep -REi 'https?://(www.)?opentabletdriver.net' \
18+
--exclude=sitemap.xml \
19+
"${HTML_ROOT}" \
20+
| grep -vE 'canonical'
21+
22+
rv="$?"
23+
24+
if [ "$rv" -eq 0 ]; then
25+
echo "OK"
26+
else
27+
echo "FAIL"
28+
fi

0 commit comments

Comments
 (0)