Does Ghost's internal link card update its anchor text when the linked post title changes?
0 reputation · 07 Nov 2023, 10:43 UTC
0 reputation · 07 Nov 2023, 10:43 UTC
I'm working with Ghost's Koenig editor and relying on the internal link feature, which lets you search for an existing post and insert a reference to it from within the editor. The documented behavior suggests the inserted link stays in sync with the target post, but I can't find a precise description of what exactly stays in sync and when.
My specific uncertainty is around title changes. If I insert an internal link to a post and later rename that post, does the anchor text in every referencing post update automatically, or only on republish? I'm also unsure whether this applies to links inserted as plain inline links versus the dedicated internal link card, and whether the sync happens at render time or is written back into the stored content. Assume a recent Ghost 5.x self-hosted install.
Related to that: does changing a linked post's slug break existing internal links, or are they resolved by post ID internally?
Finally, from an accessibility angle, do internal link cards render with meaningful semantic markup in the default theme, or is that left entirely to the theme author?
31775 reputation · 07 Nov 2023, 16:45 UTC
No — the anchor text in an internal link card does not update when the linked post's title changes. The card stores the target post's ID and the title text at the moment you insert it. Changing a linked post's slug also does not break the link, because resolution happens by post ID. In the default Casper theme the card renders as a semantic <article class="kg-card kg-card-link"> containing an <a><h3> for the title, but theme overrides can alter that markup.
<a href="/target-slug/"> elements. Those will break if the target slug changes.The core kg-card-link component shipped with Ghost outputs:
<article class="kg-card kg-card-link">
<a href="/resolved-slug/">
<h3>Stored Title</h3>
<p class="kg-card-link-description">Optional excerpt</p>
</a>
</article>This provides a heading inside a link, which is valid HTML and gives screen readers a clear label. However, themes can override the link.hbs card template. If your theme replaces that template, the semantic structure is whatever the theme author wrote.
kg-card kg-card-link structure.GET /ghost/api/admin/posts/{id}/ with formats=lexical) — the card payload contains a static title field.This answer assumes a standard Ghost 5.x self-hosted install using the Koenig/Lexical editor and the default Casper theme (or a theme that uses the built-in card components). If your theme overrides the link card template, the markup and ID-based resolution guarantees may not hold. Please confirm whether you are using a custom theme or have modified the link.hbs template — that single detail changes whether the accessibility description applies to your site.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.