kbdev
kbdev

Reputation: 1315

Wagtail 2.0 Internal Link Not Working

I'm building a site with the new version of Wagtail (2.0) and when I try to add an internal link (a link to another page in my website) in a blog post using the Rich Text Editor, the hyperlink tags are stripped out and just the link text is showing. The code that gets rendered is <a id="5" linktype="page">sample page</a>.

If I add an external link, and set it to /sample-page/ then the hyperlink works as expected.

Does anyone know why this is happening?

Upvotes: 4

Views: 1011

Answers (1)

gasman
gasman

Reputation: 25227

When you output a rich text field on your template, you need to run it through the |richtext template filter:

http://docs.wagtail.io/en/v2.0.1/topics/writing_templates.html#rich-text-filter

This is because rich text is stored as a 'symbolic' variation of HTML, where items such as page links and images are represented as IDs rather than full URLs - this ensures that they won't break if a page is moved or renamed, for example. The |richtext filter is necessary to translate that symbolic HTML back to real HTML.

Upvotes: 7

Related Questions