AstroSEO.io

Templates ยท 2026-05-31

Build Related Posts in Astro Without a Database

Generate useful related posts for a static Astro site using categories and tag overlap instead of a server-side recommendation system.

Why this matters

Related posts improve session depth and strengthen internal linking without introducing a client-side search dependency.

Setup

Score posts by shared category and tag overlap.

const categoryScore = post.data.category === current.data.category ? 2 : 0;
const tagScore = post.data.tags.filter((tag) => current.data.tags.includes(tag)).length;

Implementation notes

Use deterministic rules so the build stays reproducible. This pairs naturally with Obsidian to Astro Workflow.

Final checklist

  • Exclude the current post
  • Prefer same-category matches
  • Limit the related list to keep pages compact

Related posts