Ghost icon indicating copy to clipboard operation
Ghost copied to clipboard

Fixed ghost_head rss feed link with multiple collections

Open 9larsons opened this issue 4 months ago • 5 comments

ref https://linear.app/ghost/issue/ONC-1165/ fixes https://github.com/TryGhost/Ghost/issues/24963

  • ghost_head falls back to first listed collection when there's multiple, non-index collections in routes.yaml

Previously, ghost_head would generate an empty href="" attribute in the RSS meta tag when routes.yaml contained multiple collections but none at the root path (/), causing broken feed discovery.

Logic for the rss link tag in ghost_head is now:

  • Index collection (/) if it exists and has RSS enabled
  • Single collection's RSS if only one collection exists
  • First collection with RSS enabled when multiple collections exist
  • null if no collections have RSS enabled

9larsons avatar Sep 24 '25 14:09 9larsons

Walkthrough

Introduces clearAllRouters() to reset the routers store to an empty object. Updates resetAllRouters() to call router.reset() only when present and a function. Extends getRssUrl to handle scenarios with multiple collection routers and no index router by iterating collections to return the first available RSS URL; skips disabled (null) RSS URLs and returns nothing if all are disabled. Test suite adds beforeEach/afterEach hooks using clearAllRouters() and resetAllRoutes(), and new cases covering multiple collections without an index, disabled first RSS, and all RSS disabled. Existing tests remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely and accurately summarizes the primary fix—correcting ghost_head's RSS feed link when multiple collections are present—using a single clear sentence that a teammate can scan and understand.
Description Check ✅ Passed The description is directly related to the changeset, explains the bug, links the relevant issues, and documents the new RSS selection logic so it matches the implemented code and added tests.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch fix-rss-multiple-collections

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Sep 24 '25 14:09 coderabbitai[bot]

To my understanding, / is not intentioned to be a channel. Channels are supposed to be a division of content, while index is generally everything.

Looking through this:

  • Channel RSS feeds are always available (by default) at /channel-name/rss/
  • Channel RSS feeds have never been discoverable in ghost_head
  • If you have index set up as a channel, ghost_head would continue to have an empty or wrong url

I'm not particularly concerned with the last, because we've drawn a line that we don't make channel RSS feeds discoverable. Whether that's the correct decision is more of a product decision than a 'bug' like the issue you raised leading to this change - where we always intended to provide a discoverable RSS feed URL in ghost_head but had unhandled cases.

I had adjusted this to handle channels, though I think it's best to not handle them and leave as-is.

9larsons avatar Sep 25 '25 14:09 9larsons

I've added a new comment on the original issue, maybe it could be useful! Thanks

Link: https://github.com/TryGhost/Ghost/issues/24963#issuecomment-3483237259

ngeorger avatar Nov 06 '25 22:11 ngeorger

@ngeorger I don't think this patch quite fixes the case you added to the issue, since you've got a channel at /. I left you a theme-level fix.

@9larsons , see! I'm not the only one who wants to put a channel at / ! 😀

cathysarisky avatar Nov 06 '25 22:11 cathysarisky

How we could know if this PR is going to be accepted/merged? Thanks a lot!

ngeorger avatar Dec 06 '25 23:12 ngeorger