Skip to content

Fix richtext rendering#601

Merged
vossisboss merged 3 commits intowagtail:mainfrom
yuvrajsingh0125:fix-richtext-rendering
Mar 3, 2026
Merged

Fix richtext rendering#601
vossisboss merged 3 commits intowagtail:mainfrom
yuvrajsingh0125:fix-richtext-rendering

Conversation

@yuvrajsingh0125
Copy link
Contributor

Fixes #600

The intro field (RichTextField) was being rendered directly in the template, which caused raw HTML to appear instead of properly formatted content.

This update applies the |richtext filter to ensure correct and safe HTML rendering, following Wagtail's standard rendering practices.

@zerolab zerolab self-assigned this Mar 2, 2026
@vossisboss
Copy link
Collaborator

vossisboss commented Mar 2, 2026

Yup. This is a legit error. We probably didn't catch it before because we don't usually put non-blog pages in the Related pages section. I'll test this real quick and get this merged. Thanks for the quick fix @yuvrajsingh0125!

@vossisboss
Copy link
Collaborator

Huh. Good thing I tested this on staging first. There's something weird happening with the spacing now that the HTML is being filtered properly. This might not be as quick a fix as I was hoping for.

Screenshot 2026-03-02 at 4 07 48 PM

@vossisboss
Copy link
Collaborator

Yeah, it looks like the issue isn't just adding a filter because the formatting problem is unique to the Roadmap page type. I suspect it's because there is a URL included in the Roadmap page introduction and the classes are causing issues. When I added other page types that were not blog pages, the formatting was fine. See example here with the Sponsor Wagtail page:

Screenshot 2026-03-02 at 5 22 42 PM

@vossisboss
Copy link
Collaborator

Adding the |striptags filter solves the problem being caused by the <a> tags. Preserving the hyperlink in the preview card isn't necessary. We should revisit the design, but this fix solves the issue raised in #600 for now.

Co-authored-by: Meagen Voss <45881480+vossisboss@users.noreply.github.com>
@yuvrajsingh0125
Copy link
Contributor Author

Thanks for testing this and digging deeper.

That makes sense since this is a preview card, stripping the tags instead of rendering full rich text seems more appropriate.

I'll update the template to apply striptags as suggested.

@zerolab
Copy link
Contributor

zerolab commented Mar 3, 2026

@yuvrajsingh0125 I've already applied the suggestions from @vossisboss

@vossisboss
Copy link
Collaborator

This all looks good to me and looks good on staging. I'm going to merge this now.

@vossisboss vossisboss merged commit 09ff97a into wagtail:main Mar 3, 2026
3 checks passed
@yuvrajsingh0125
Copy link
Contributor Author

Thanks for the review and for applying the refinements, I really appreciate the feedback!

vossisboss added a commit that referenced this pull request Mar 12, 2026
* Fix rich text rendering in related page card block using richtext filter

* Fix typo in richtext filter

* Apply suggestions from code review

Co-authored-by: Meagen Voss <45881480+vossisboss@users.noreply.github.com>

---------

Co-authored-by: Dan Braghiș <31622+zerolab@users.noreply.github.com>
Co-authored-by: Meagen Voss <45881480+vossisboss@users.noreply.github.com>
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.

richtext not rendered as html for related roadmap

3 participants