Skip to content

Strip image alt text from post excerpts - #268

Merged
ohookins merged 1 commit into
mainfrom
fix/excerpt-image-alt-text
Aug 16, 2026
Merged

Strip image alt text from post excerpts#268
ohookins merged 1 commit into
mainfrom
fix/excerpt-image-alt-text

Conversation

@ohookins

Copy link
Copy Markdown
Owner

Fixes #266 — image alt text was appearing in post summaries on the index and tag pages.

Problem

gatsby-transformer-remark's plain text excerpt includes image alt text as regular text content. A post starting with ![hello world](image.jpg) would show "hello world" at the start of its summary.

Fix

  • Changed the excerpt query from plain text to format: HTML
  • Strip <img> tags from the HTML excerpt before rendering
  • Applied to both the index template and tag template

Switch excerpt format to HTML and strip <img> tags before rendering.
Previously, image alt text from markdown (e.g. ![caption](url)) would
appear as plain text in the summary, which was confusing.

Closes #266
@ohookins
ohookins merged commit 3931b37 into main Aug 16, 2026
4 checks passed
@ohookins
ohookins deleted the fix/excerpt-image-alt-text branch August 16, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Images at the start of a blog post are rendered incorrectly in the summary

1 participant