scythargon
scythargon

Reputation: 3491

Wagtail: Is it possible to disable prepending internal link's with the site domain?

I want to make the urls which I put in the WYSIWYG editor just absolute like /something but not sitename.com/something. I know that I can use the "external link" option, but it is not very handy for my editors.

Upvotes: 0

Views: 247

Answers (1)

gasman
gasman

Reputation: 25227

If your rich text fields are outputting full URLs including a domain, it probably means you're hosting multiple sites on the same Wagtail installation. Unfortunately, in this situation it's not possible to override this behaviour to output local URLs.

Wagtail will always prefer to generate local URLs (without a domain) wherever possible, according to the following rules:

  1. If the Wagtail installation is only hosting one site, generate a local URL
  2. If we know that the link is being output on a page that's on the same site as the link destination, generate a local URL
  3. Otherwise, generate a full URL including the domain

In the case of rule 2, the {% pageurl %} template tag is able to compare the current page against the link destination. However, this isn't possible within the |richtext template filter: a Django template filter has no access to the calling template's variables, so there's no way for it to know that the current page matches the link destination.

Upvotes: 2

Related Questions