A growing technical blog needs more than an endless list of articles. Once you have tutorials about Astro, n8n, Cloudflare, automation, and SEO, visitors should be able to explore a topic without knowing the exact title of the next post.
Tag archives solve this problem by grouping articles under stable topic URLs such as /tags/astro/ and /tags/cloudflare-pages/. They can create useful internal links and improve browsing. But generating a page for every arbitrary keyword also introduces risks: duplicate slugs, almost-empty archives, misleading article counts, and links to unpublished content.
In this practical guide, you will build static tag archive pages in Astro from a Decap CMS-managed content collection, test the indexing and routing behavior, and decide when an archive deserves to be published. The implementation is intentionally lightweight: no client-side framework, database, or paid SEO plugin.
Important: This is an adaptable tutorial, not code verified against a private production repository. If your Astro site already has category archive pages, leave them in place. Tags serve a different purpose and should use their own routes.
1. What you will build
The result is a small taxonomy system with two public URL patterns:
/tags/— an accessible index of topics that have enough published articles./tags/[tag]/— a static landing page listing published articles about one topic.
Your editorial team will add tags in Decap CMS. Astro will read the collection at build time, normalize tag names into URL-safe slugs, filter draft and scheduled articles, and generate the final HTML. Individual posts can link to those topic pages using a shared helper.
We will also use a simple editorial threshold: only generate an archive when it contains at least two published posts. That number is a project choice, not a requirement or ranking signal from Google. It prevents a new tag from automatically becoming a one-link landing page before you have time to curate it.
2. Categories, tags, and related posts are not the same
| Feature | Primary question | Example | Recommended role |
|---|---|---|---|
| Category | What broad section is this article in? | Tutorials | Main site navigation |
| Tag | Which specific topic does it cover? | Astro, Decap CMS | Topic exploration |
| Related posts | What should I read next? | Three relevant tutorials | Contextual suggestions |
A category might contain every web-development tutorial. A tag should normally describe a narrower, reusable subject. One article can have several tags, while its primary category can remain unchanged.
An archive of every possible word in your article title is not helpful taxonomy. Avoid interchangeable labels like Astro CMS, Astro + CMS, and Astro Content CMS unless they represent truly different reader intents. Start with a small vocabulary and expand only as your content warrants.
3. Understand the publishing architecture
Here is the full flow:
- An editor adds a list of tags to a Markdown article in Decap CMS.
- The article reaches the published branch through the existing editorial workflow.
- Astro loads the published content collection.
- A shared helper filters unpublished articles and normalizes tags.
getStaticPaths()generates routes for eligible tag archives.- Cloudflare Pages serves the resulting static HTML with ordinary links.

Figure 1. All tag archive pages are generated at build time, so readers do not need JavaScript to browse them.
This is different from a search page: there is no live query or client-side filtering. It is also different from a Related Posts component, which can show suggestions without creating a dedicated landing page for the topic.
4. Audit your existing routes and content model first
Before writing a new component, inspect your project for existing routes, metadata, and taxonomies:
src/content.config.ts
src/content/blog/
src/pages/blog/
src/pages/tags/
src/pages/category/
public/admin/config.yml
Some Astro sites use src/content/config.ts or older collection conventions. Others use a custom loader, MDX, or manually imported Markdown. Do not add a second collection config just because this guide uses the current src/content.config.ts convention.
Confirm four things:
- The collection’s name is really
blog(or update all examples consistently). - Publication date and draft fields are named
pubDateanddraft, or adapt the helper to the names you actually use. - Existing post URLs follow
/blog/<slug>/; don’t guess a URL from the filename if frontmatter overrides it. - Neither
/tags/nor/tags/[tag]/is already owned by another route, rewrite rule, or Pages Function.
If your website already has /category/tutorials/, do not replace its layout or path. You can link it from the tag index without changing how categories work.
5. Add a tags field in Decap CMS
Decap CMS provides a built-in list widget that can save a list of strings in Markdown frontmatter. Add only this field under the fields array of your existing blog collection in public/admin/config.yml (the location may differ in your project):
- label: Tags
name: tags
widget: list
required: false
default: []
hint: 'Use a few consistent topics, such as Astro, n8n, or SEO.'
Decap’s list widget is the appropriate shape for tags such as:
---
title: "Build a Secure Astro Contact Form"
pubDate: 2026-11-05
draft: false
category: Tutorials
tags:
- Astro
- Cloudflare Pages
- Security
---
required: false lets you migrate existing articles gradually. Set default: [] in your Astro schema too, so missing tags are treated consistently. For a heavily edited publication, you may prefer a controlled list or select widget instead of allowing every editor to invent new tags.
Do not paste the YAML snippet above as an entire Decap CMS config. Preserve the existing GitHub backend, authentication, editorial workflow, collections, media folders, and image settings.
6. Validate tags in the Astro content collection
For Astro’s modern Content Collections API, a glob() loader and Zod schema can parse Markdown frontmatter. Add the tags field to the schema you already maintain:
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
const blog = defineCollection({
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/blog' }),
schema: z.object({
title: z.string().min(1),
description: z.string().min(1),
pubDate: z.coerce.date(),
draft: z.boolean().default(false),
slug: z.string().optional(),
category: z.string().optional(),
tags: z.array(z.string()).default([]),
}),
});
export const collections = { blog };
This is a standalone reference schema, not a replacement for your current one. Your real site may have additional required metadata (hero image, author, update date, or custom slug), and a loader may use different options. Merge only the relevant field. If Decap CMS stores date rather than pubDate, update the sample consistently.
Schema validation protects data shape, but does not make every tag meaningful or prevent two different names from generating the same URL. We will handle those issues separately.
7. Create a reusable tag archive helper
Create src/lib/tag-archives.mjs. The complete implementation is included as a separate file in the downloadable code package; its key functions are:
export function tagSlug(label) {
return String(label)
.normalize('NFKD')
.replace(/\p{M}/gu, '')
.toLowerCase()
.replace(/&/g, ' and ')
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
}
export function isPublished(post, now = new Date()) {
const date = new Date(post.data.pubDate);
return post.data.draft !== true &&
Number.isFinite(date.getTime()) &&
date.getTime() <= now.getTime();
}
Build getTagArchives(posts, { now, minPosts }) around these functions. It should group published posts by normalized tag slug, deduplicate tags assigned twice to the same article, sort posts by publication date, and return archives in a stable order.
For example, these four Markdown entries:
| Article | Tags | Published? |
|---|---|---|
| A | Astro, SEO | Yes |
| B | Astro, Decap CMS | Yes |
| C | Astro | Draft |
| D | SEO | Scheduled for next month |
produce one eligible archive with a two-post threshold: /tags/astro/, containing only A and B. The two other tags do not yet have two published articles.
A crucial detail: map to the site’s real article slug
A typical helper might construct a post URL as follows:
export function postHref(post) {
const raw = post.data.slug || post.id;
return `/blog/${String(raw).replace(/^\/+|\/+$/g, '')}/`;
}
Do not assume this matches your own site. If the article router derives its URL from a filename, stores a precomputed slug, or uses nested IDs, reuse its existing URL function. Incorrect links undermine the purpose of an archive.
8. Prevent unpublished posts and colliding tag slugs
Two protections are worth implementing before any UI work.
Publication filtering: Both draft: true and a future pubDate should exclude an article from the archive. A scheduled post does not automatically appear at midnight on a static site; the site needs another build after its publication time arrives.
Collision detection: An ASCII-oriented slug function may turn both C++ and C# into c. Silently combining unrelated topics would be incorrect. If two distinct normalized labels resolve to the same slug, stop the build with an actionable error and decide on an editorially explicit slug.
The helper in the code package throws an error for collisions, invalid tag values, and tags that normalize to an empty slug. It is intentionally conservative rather than quietly publishing a misleading route.

Figure 2. Publication rules, slug checks, and a curated tag vocabulary prevent broken topic pages.
If your content contains non-Latin tags, C++, or punctuation-heavy technical terms, consider an explicit tag-to-slug registry instead of the simple ASCII function shown above.
9. Build the /tags/ index page
Create src/pages/tags/index.astro. It can load the collection once and derive public archives:
---
import { getCollection } from 'astro:content';
import { getTagArchives } from '../../lib/tag-archives.mjs';
const archives = getTagArchives(await getCollection('blog'));
---
<main>
<h1>Explore Topics</h1>
<p>Browse practical articles grouped by technology and subject.</p>
<ul>
{archives.map(({ slug, label, posts }) => (
<li>
<a href={`/tags/${slug}/`}>{label}</a>
<span> — {posts.length} articles</span>
</li>
))}
</ul>
</main>
For production, render this inside your existing shared layout rather than copying a second header, footer, analytics component, or SEO metadata system. Show an editorial empty-state message when no tags qualify yet; do not invent topic links.
The index page should have a useful introduction and descriptive anchor text. It should not become an uncontrolled cloud of hundreds of near-identical terms.
10. Generate /tags/[tag]/ pages using getStaticPaths()
Astro’s static routing uses getStaticPaths() to produce a set of pages from a dynamic filename. In src/pages/tags/[tag].astro:
---
import { getCollection } from 'astro:content';
import { getTagArchives, postHref } from '../../lib/tag-archives.mjs';
export async function getStaticPaths() {
const archives = getTagArchives(await getCollection('blog'));
return archives.map((archive) => ({
params: { tag: archive.slug },
props: { archive },
}));
}
const { archive } = Astro.props;
---
<main>
<nav aria-label="Breadcrumb">
<a href="/">Home</a> / <a href="/tags/">Tags</a> / {archive.label}
</nav>
<h1>{archive.label}</h1>
<p>Explore our articles about {archive.label}.</p>
<ul>
{archive.posts.map((post) => (
<li><a href={postHref(post)}>{post.data.title}</a></li>
))}
</ul>
</main>
The full code package adds date markup, SEO placeholders, and an accessible page structure. It does not overwrite your existing article layout. If your project uses on-demand rendering rather than static generation, check the relevant prerender behavior in Astro’s routing documentation.
Why stable static URLs matter
/tags/astro/ should continue to mean the same topic over time. If you rename a public tag to a new slug, add a permanent redirect from the old URL and update internal links and canonical metadata. Do not silently delete an established page with inbound links.
11. Add tag chips to existing articles
Your article template can show links such as #Astro, #SEO, and #Cloudflare Pages. But each visible chip must point to a published archive that actually exists.
Avoid generating /tags/new-topic/ links when the archive is deliberately withheld because it contains only one published article. The sample TagChips.example.astro accepts the list of valid archive slugs as a prop and hides unavailable links. Compute that list once in the parent, not repeatedly for every article card.
Use ordinary HTML anchors. They work with keyboards, screen readers, search engine crawlers, and JavaScript-disabled browsers. Tags are navigation, not buttons that require JavaScript click handlers.
12. Add useful metadata without duplicating your SEO component
A tag archive should generally have its own title, clear heading, descriptive introduction, and canonical URL. Examples:
Page title: Astro Tutorials and Guides | Example Blog
Canonical: https://example.com/tags/astro/
Description: Explore practical Astro tutorials on CMS workflows,
performance, SEO, and deployment.
Use your real domain and existing trailing-slash policy. If your shared Astro layout already generates canonical tags, do not add a second one in [tag].astro.
Also check your existing sitemap setup. Some Astro sitemap integrations can include static routes generated at build time automatically, depending on configuration. Verify the deployed sitemap-index.xml or relevant sitemap files rather than manually adding conflicting entries.
A tag archive is not an individual article. Do not attach BlogPosting structured data to the archive as if it were a standalone tutorial. If you generate breadcrumbs, ensure they match the actual navigation and avoid duplicating schema already emitted by your layout.
13. Avoid low-value archives and SEO myths
More indexable URLs do not automatically create more SEO traffic. A poorly curated tag system can produce near-identical pages with one article, identical descriptions, and little reason for users to visit them.
A practical editorial approach is to:
- Maintain a small set of stable topics tied to actual reader needs.
- Prefer two or more genuinely relevant articles before adding a new public tag page.
- Add a short, distinctive description for important tag pages when the publication grows.
- Avoid creating many near-duplicate tags for the same concept.
- Keep every archive internally linked and reachable through the site UI.
- Review tag pages periodically when posts move, are unpublished, or are renamed.
The two-post threshold in this tutorial is not a Google policy. It is a useful starting constraint for a small blog. One excellent, well-written archive may be more valuable than several shallow ones; evaluate content quality rather than just article count.
Google’s crawling guidance warns that uncontrolled faceted navigation can create an enormous number of low-value URLs. A curated tag taxonomy is much smaller than a product filter system, but the underlying lesson applies: do not create effectively unlimited, repetitive combinations of pages without reader value.
14. Test the complete publishing workflow
Before deploying, run a clean build and inspect the generated routes:
npm run build
On Windows PowerShell, where npm may be affected by shell execution policies, you can use:
npm.cmd run build
Then verify all of the following:
| Test | Expected result |
|---|---|
/tags/ |
Lists only eligible, published topics |
/tags/astro/ |
Contains the correct published articles |
| Draft article | Does not appear on any archive |
| Future-dated article | Appears only after a subsequent qualifying build |
| Duplicate tag values | Do not duplicate a post card |
| Collision such as C++ / C# | Fails validation rather than merging silently |
| Tag chips | Point only to generated URLs |
| Canonical URL | Matches your preferred domain and slash format |
| Existing category pages | Continue working unchanged |
| SEO metadata | Appears once, with no contradictory tags |

Figure 3. Validate both user-visible navigation and build-time behavior before exposing new archive URLs.
For a static site, test a deployment preview and then spot-check real published pages. A successful build alone does not prove all links match the live article router.
15. Add automated tests for the taxonomy helper
Since the grouping logic is written as a standalone .mjs module, you can test it without importing the entire Astro site. Node’s built-in test runner is sufficient:
node --test tests/tag-archives.test.mjs
Useful cases include:
import assert from 'node:assert/strict';
import { tagSlug } from '../src/lib/tag-archives.mjs';
assert.equal(tagSlug('Cloudflare Pages'), 'cloudflare-pages');
assert.equal(tagSlug('SEO & Astro'), 'seo-and-astro');
The downloadable package contains tests for draft/future filtering, tag normalization, archive eligibility, stable ordering, correct example article URLs, and slug collisions. These unit tests were run with Node.js, but they are not a substitute for building your actual Astro repository.
16. Troubleshoot common implementation problems
| Problem | Likely cause | How to investigate |
|---|---|---|
/tags/ is empty |
Existing posts have no tags or do not meet the threshold | Inspect actual published frontmatter; temporarily test minPosts: 1 |
| Tag page is not generated | getStaticPaths() did not return its slug |
Check collection loading, publication filter, and console errors |
| Tag chip returns 404 | UI links to a tag that was not built | Share the same archive list between the router and chip component |
| Article link is wrong | postHref() uses an ID different from the real slug |
Reuse your existing article URL helper |
| Two topics become one URL | Slug collision | Define distinct, editorially approved slugs |
| Scheduled article is missing after midnight | No rebuild occurred | Trigger a new static build or deploy |
| Duplicate canonical tags | Route and shared SEO layout both generate one | Keep metadata in one consistent source |
| Category page changes unexpectedly | New code overwrote an existing archive route | Restore its prior implementation and add tags separately |
| A renamed tag loses old traffic | Existing URL vanished without redirect | Add a redirect and update references |
Do not solve these issues by weakening validation or generating every possible URL. Fix the source-of-truth mapping first.
17. Frequently asked questions
Do tag archive pages improve rankings automatically?
No. They can help navigation and internal linking, but they do not provide a guaranteed ranking boost. Thin, repetitive pages can add maintenance without meaningful reader benefit.
Should every article have five or ten tags?
Not necessarily. A small number of accurate, reusable tags is better than padding each article with keywords. Choose topics that another reader would genuinely browse.
Can I keep my existing category pages?
Yes. The example deliberately uses /tags/ routes and does not replace /category/ or the current Decap CMS category field.
What happens to an unpublished article?
The helper excludes drafts and posts with future publication dates. Because archive HTML is generated during a static build, the public site needs a rebuild after the scheduled date.
Why not index every one-post tag page?
You can if it genuinely serves a reader need. This tutorial uses a two-post editorial minimum to avoid automatically publishing near-empty archives. There is no universal minimum required by Google.
Is the slug function safe for all languages and programming tags?
No. The simple ASCII-oriented implementation needs an explicit mapping strategy for symbols such as C#, C++, or multilingual terms. It deliberately throws on collisions instead of silently merging unrelated topics.
Do I need to install another Astro plugin?
No. The implementation uses Content Collections, static routing, and a small utility module. Your existing sitemap and SEO integrations may already cover the remaining metadata requirements.
18. Final thoughts
A useful tag system is an editorial tool, not a way to manufacture more URLs. Start with a carefully chosen vocabulary, generate stable routes from published content, and make every tag page valuable to someone exploring the subject.
In an Astro and Decap CMS workflow, the strongest design is also the simplest: one source of truth for tag names and slugs, a shared publication filter, static pages, descriptive links, and a small automated test suite.
Inspect your existing content schema and routes before integrating the examples. Add tag archives without breaking category pages, article URLs, search, or canonical metadata. Then test the preview, review the published output, and improve your tag descriptions as the site grows.
Official references and related reading
Official documentation:
- Astro — Content Collections
- Astro — Routing and getStaticPaths
- Decap CMS — List widget
- Google — Managing crawling of faceted navigation URLs
Continue reading on DuongHoangNam.com:
- How to Build an Astro Blog with Decap CMS and Cloudflare Pages
- Astro SEO Guide 2026: 12 Essential Steps to Optimize Your Website for Google
- How to Add Structured Data to Astro: BlogPosting, Breadcrumbs & JSON-LD
Implementation note: The provided files are reference examples, not a tested patch for your repository. Adapt field names, route helpers, layouts, and SEO components before deployment.






