Issue with markdown code showing in PostCard excerpts

Hi, I’m building a Gatsby/Ghost Jamstack site.

I’ve noticed that when I don’t set a manual story excerpt in Ghost, the excerpts in PostCard’s show markdown code rather than the correct formatting for links etc.

Example here:

Is this a fixable issue or do I need to manually set story excerpts?

Any help appreciated. Thanks!

Hi @shylands! This issue is happening due to the fact that we calculate our excerpts based on plaintext extracted from post’s HTML content. Here is output for regular posts without markdown:

<p>regular text with <a href=\"https://ghost.org\">link</a></p>

produced this plaintext format and excerpt:

regular text with link [https://ghost.org]

So at the moment, there is no other workaround except for setting custom excerpts when you need to have a link in the excerpts. But this is a valid use case to improve upon and we had it discussed before in Improvements to the {{excerpt}} helper · Issue #5060 · TryGhost/Ghost · GitHub, might be worth revisited if this becomes a very demanded use case :)

Just to be clear, the automatic excerpts are not markdown, they are a plaintext representation of a post that uses commonly understood characters to replace formatting.

Markdown would be regular text with [link](https://ghost.org). It’s similar, but not the same :slight_smile:

The underlying problem here is that auto-excerpts have to be generated from the potentially complex HTML that is your post content, where some of it makes sense as an excerpt, and some doesn’t.

Auto-excerpts used to strip all HTML, so you wouldn’t have had the link present at all. Issue 5060 (posted above) represents an old idea we had for a more technically advanced feature to trim down HTML, but it didn’t really get any traction.

For now, we’ve opted for the simplest option available, instead of stripping all HTML, we use the already-present plaintext form of your post content, which at least includes the link.

Now you have different options and control:

  • You can trust the auto-excerpt feature to at least be an accurate representation of the content you have. Where this doesn’t work, you can override with a custom excerpt
  • If you don’t like this, you can switch to using the content helper directly instead of the excerpt helper, but then you have to make sure that the first X portion of your content is exactly what you want to appear
  • Alternatively, you can manually implement logic to use the custom excerpt if available, and fall back to the content helper.

If none of this gives you what you want, you can post your idea for how you would like this to work (or vote on an existing idea) in the Ideas part of the forum.

1 Like

Ah ok thanks for all the info. Great help. I’m going to manually set the excerpts. Cheers!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.