Skip to content

Commit

Permalink
Add taxonomies to sitemap (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemartin authored Jun 6, 2023
1 parent 7c4b793 commit 1882344
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
46 changes: 46 additions & 0 deletions resources/fieldsets/globals_seo_sitemap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,49 @@ fields:
default: pages
display: Collections
width: 50
-
handle: sitemap_taxonomies
field:
mode: select
type: taxonomies
instructions: 'Select which taxonomies to include in the sitemap.xml.'
listable: hidden
display: Taxonomies
width: 50
instructions_position: above
visibility: visible
hide_display: false
-
handle: sitemap_collection_taxonomies
field:
fields:
-
handle: taxonomy
field:
max_items: 1
mode: select
type: taxonomies
listable: hidden
display: Taxonomy
width: 50
instructions_position: above
visibility: visible
hide_display: false
instructions: 'Select which taxonomy to use for specified collections.'
-
handle: collections
field:
mode: select
type: collections
listable: hidden
display: Collections
width: 50
instructions: "Select collections to assign the taxonomy's term urls."
mode: stacked
add_row: 'Add collection taxonomy'
reorderable: true
display: 'Collection Taxonomies'
type: grid
icon: grid
instructions: 'Select which collection term urls to include in the sitemap.xml. For example: _/blog/tags/retrowave_.'
listable: hidden
28 changes: 27 additions & 1 deletion resources/views/sitemap/sitemap.antlers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,30 @@
{{ /results }}
{{ /collection }}
{{ /seo:sitemap_collections }}
</urlset>
{{ seo:sitemap_taxonomies }}
{{ taxonomy 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>
</url>
{{ /results }}
{{ /taxonomy }}
{{ /seo:sitemap_taxonomies }}
{{ seo:sitemap_collection_taxonomies }}
{{ collections }}
{{ taxonomy from="{taxonomy}" collection="{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>
</url>
{{ /results }}
{{ /taxonomy }}
{{ /collections }}
{{ /seo:sitemap_collection_taxonomies }}
</urlset>

0 comments on commit 1882344

Please sign in to comment.