Skip to content

Commit

Permalink
feat: generate sitemap.xml (resolves #243) (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
jobara authored Apr 11, 2022
1 parent 5888b5a commit cea3049
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 1 deletion.
9 changes: 9 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
autoLaunch = false
framework = "#custom"

[[headers]]
for = "/admin/*"
[headers.values]
X-Robots-Tag = "noindex"

[[headers]]
for = "**/404.html"
[headers.values]
X-Robots-Tag = "noindex"

[[redirects]]
from = "/fr/*"
Expand Down
1 change: 1 addition & 0 deletions src/404.en-CA.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ title: Page Not Found
lang: en-CA
translationKey: 404
permalink: "{% if lang != config.defaultLanguage %}/{{ config.languages[lang].slug }}{% endif %}/404.html"
eleventyExcludeFromCollections: true
---
The page you were looking for does not exist. Go back to the [home page?](/)
1 change: 1 addition & 0 deletions src/404.fr-CA.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ title: Page non trouvée
lang: fr-CA
translationKey: 404
permalink: "{% if lang != config.defaultLanguage %}/{{ config.languages[lang].slug }}{% endif %}/404.html"
eleventyExcludeFromCollections: true
---
La page que vous recherchez n'existe pas. Retournez à la [page d'accueil?](/fr/)
1 change: 1 addition & 0 deletions src/admin/admin.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
permalink: '/admin/index.html'
eleventyExcludeFromCollections: true
---
<!doctype html>
<html>
Expand Down
2 changes: 1 addition & 1 deletion src/admin/config.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
permalink: /admin/config.yml
eleventyExcludeFromCollections: true
---
backend:
name: git-gateway
Expand Down Expand Up @@ -67,4 +68,3 @@ collections:
- { label: "Author Name", name: authorName, widget: string, i18n: true }
- { label: "Author Email", name: authorEmail, widget: string, i18n: duplicate }
- { label: "Author Website", name: authorWebsite, widget: string, i18n: duplicate }

1 change: 1 addition & 0 deletions src/feed.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pagination:
size: 1
alias: language
permalink: "{% if language !== config.defaultLanguage %}/{{ config.languages[language].slug }}{% endif %}/feed.xml"
eleventyExcludeFromCollections: true
---
{% set collection = "postFeed_" + language %}
<?xml version="1.0" encoding="utf-8"?>
Expand Down
9 changes: 9 additions & 0 deletions src/robots.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
permalink: /robots.txt
eleventyExcludeFromCollections: true
---
Sitemap: {{ site[config.defaultLanguage].url }}/sitemap.xml

User-Agent: *
Disallow: /404.html
Disallow: /admin/
20 changes: 20 additions & 0 deletions src/sitemap.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
permalink: /sitemap.xml
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
{% for page in collections.all %}
{% if page.url -%}
<url>
<loc>{{ site[config.defaultLanguage].url }}{{ page.url | url }}</loc>
<lastmod>{{ page.date.toISOString() }}</lastmod>
{% for relatedPage in collections.all -%}
{% if page.data.translationKey and page.data.translationKey ===relatedPage.data.translationKey %}
<xhtml:link rel="alternate" hreflang="{{ relatedPage.data.lang}}" href="{{ site[config.defaultLanguage].url }}{{ relatedPage.url }}"/>
{%- endif %}
{%- endfor %}
</url>
{%- endif %}
{% endfor %}
</urlset>
1 change: 1 addition & 0 deletions src/webmanifest.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
permalink: /manifest.webmanifest
eleventyExcludeFromCollections: true
---
{
"icons": [
Expand Down

0 comments on commit cea3049

Please sign in to comment.