Skip to content

Hide draft blog posts from listings, feeds, and search#3065

Merged
atharvadeosthale merged 1 commit into
stardustfrom
stardust-blog-drafts
Jun 29, 2026
Merged

Hide draft blog posts from listings, feeds, and search#3065
atharvadeosthale merged 1 commit into
stardustfrom
stardust-blog-drafts

Conversation

@atharvadeosthale

Copy link
Copy Markdown
Member

What

Makes draft: true in a blog post's frontmatter hide the post everywhere except its own direct URL.

A draft post:

  • stays reachable at /blog/post/<slug> (renders normally)
  • is excluded from: the blog listing (plus the featured hero and pagination), author pages, category pages and chips, the "read next" list, RSS (/blog/rss.xml), the JSON feed (/blog/feed.json), and llms.txt / llms-full.txt
  • emits <meta name="robots" content="noindex"> so search engines drop it while the URL stays live

How

A single source of truth: a new publishedPosts (non-draft) export in blog/content.ts, reused by:

  • the blog layout context (covers author pages, category pages, and "read next")
  • getBlogEntries() for the listing and category chips
  • both feeds (rss.xml, feed.json)
  • both llms generators (matched by slug)

Post.svelte gains a draft prop and the conditional noindex meta. The post route itself is untouched, so the URL keeps working. unlisted behavior is unchanged.

Testing

  • svelte-check: 0 errors, 0 warnings
  • Verified with a browser (Playwright) and curl: the draft is absent from every listing/feed surface, present only at its direct URL with noindex; published posts are unaffected

Call-outs (not included here)

  • The sitemap (server/sitemap.js) builds from the route manifest, not frontmatter, so a draft URL can still appear in sitemap.xml. noindex still prevents indexing; excluding it from the sitemap would be a small follow-up.
  • On-site search is handled by an external Meilisearch crawler, which is not guaranteed to skip drafts from this change alone.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet