Skip to content

Commit

Permalink
Filter out entries without permalink in sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
robdekort committed Feb 14, 2024
1 parent 8d0edc8 commit 7a7ec41
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions resources/views/sitemap/sitemap.antlers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" {{ yield:namespace }}>
{{ seo:sitemap_collections }}
{{ collection from="{handle}" seo_noindex:isnt="true" as="results" }}
{{ results }}
<url>
<loc>{{ permalink }}</loc>
<lastmod>{{ updated_at format="Y-m-d"}}</lastmod>
<changefreq>{{ sitemap_change_frequency ? sitemap_change_frequency : 'weekly' }}</changefreq>
<priority>{{ sitemap_priority ? sitemap_priority : '0.5' }}</priority>
{{ if {locales:count} > 1 }}
{{ once }}
{{ section:namespace}}
xmlns:xhtml="http://www.w3.org/1999/xhtml"
{{ /section:namespace}}
{{ /once }}
{{ locales }}
<xhtml:link rel="alternate" hreflang="{{ locale:full }}" href="{{ permalink }}"/>
{{ /locales }}
{{ /if }}
</url>
{{ results where (x => x.permalink !== null) }}
{{ if permalink }}
<url>
<loc>{{ permalink }}</loc>
<lastmod>{{ updated_at format="Y-m-d"}}</lastmod>
<changefreq>{{ sitemap_change_frequency ? sitemap_change_frequency : 'weekly' }}</changefreq>
<priority>{{ sitemap_priority ? sitemap_priority : '0.5' }}</priority>
{{ if {locales:count} > 1 }}
{{ once }}
{{ section:namespace}}
xmlns:xhtml="http://www.w3.org/1999/xhtml"
{{ /section:namespace}}
{{ /once }}
{{ locales }}
<xhtml:link rel="alternate" hreflang="{{ locale:full }}" href="{{ permalink }}"/>
{{ /locales }}
{{ /if }}
</url>
{{ /if }}
{{ /results }}
{{ /collection }}
{{ /seo:sitemap_collections }}
{{ seo:sitemap_taxonomies }}
{{ taxonomy from="{handle}" seo_noindex:isnt="true" as="results" }}
{{ results }}
{{ results where (x => x.permalink !== null) }}
<url>
<loc>{{ permalink }}</loc>
<lastmod>{{ updated_at format="Y-m-d"}}</lastmod>
Expand All @@ -48,4 +50,4 @@
{{ /taxonomy }}
{{ /collections }}
{{ /seo:sitemap_collection_taxonomies }}
</urlset>
</urlset>

0 comments on commit 7a7ec41

Please sign in to comment.