Skip to content

Commit

Permalink
Fixed sitemap to exclude pages with do-not-crawl tag. Fixed such page…
Browse files Browse the repository at this point in the history
…s to include correct robots directive.
  • Loading branch information
jbum committed Aug 9, 2024
1 parent ca1f64a commit 37e68c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions pages/_data/eleventyComputed.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,15 @@ module.exports = async () => {
if (!perfAudits) {
perfAudits = await fetch(perfApiUrl).then((res) => res.json());
}

return {
title: (article) => article?.data?.title || article.title,
id: (article) => article?.data?.id,
date: (article) => article?.data?.date || article.date,
publishdate: (article) =>
article?.data?.date.split("T")[0] || article.publishdate,
publishdate: (article) => article?.data?.date.split("T")[0] || article.publishdate,
meta: (article) => article?.data?.excerpt || article.meta,
description: (article) => article?.data?.excerpt || article.meta,
author: (article) => article?.data?.author || article.author,
tags: (article) => (isPost(article) ? ["news"] : article.tags),
tags: (article) => article?.data?.tags || (isPost(article) ? ["news"] : article.tags),
permalink: (article) => getPermalink(article),
layout: (article) => getLayout(article),
eleventyNavigation: (article) => getNavigation(article),
Expand Down
14 changes: 7 additions & 7 deletions pages/manual-content/sitemap.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ eleventyExcludeFromCollections: true
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for page in collections.all %}
{% if not sitemap.urls[page.url | url ].exclude %}
<url>
<loc>https://innovation.ca.gov{{ page.url | url }}</loc>
<lastmod>{{ page.date.toISOString() }}</lastmod>
<changefreq>daily</changefreq>
</url>
{% endif %}
{% if (page.data.tags and not page.data.tags.includes('do-not-crawl')) and not sitemap.urls[page.url | url ].exclude %}
<url>
<loc>https://innovation.ca.gov{{ page.url | url }}</loc>
<lastmod>{{ page.date.toISOString() }}</lastmod>
<changefreq>daily</changefreq>
</url>
{% endif %}
{% endfor %}
</urlset>

0 comments on commit 37e68c2

Please sign in to comment.