How can I make a absolute-path reference in an anchor tag?

  • What version of Ghost are you using? Ghost-CLI at 1.13.1, Ghost version 3.14.4, Node v12.16.2 on Ubuntu 16

My blog is served at https://mydomain/blog/ and reverse-proxied via nginx.

In a post, I need to place an anchor tag with an absolute-path reference. This is a link to a relative path beginning with a “/” character. For example, <a href="/foo">foo</a>.

When I try to make an absolute-path reference in my post content, the path is converted to an absolute-URI link, but it uses the full blog url instead of just the domain, so it becomes https://mydomain/blog/foo. This breaks the link completely. I actually want it to point to /foo on whatever domain or scheme I’m using.

How can I create an anchor tag that doesn’t get converted to an absolute-URI?

(At the very least, transforming it from /foo to /blog/foo seems most incorrect. If it was transformed to https://mydomain/foo that would be sufficient)

Completely turning off the automatic url modification would also be a great solution, if possible. Can’t figure out how to do that though.

So I’ve found that when you save a post, absolute-path references are maintained correctly in the DB - at least, the first time you save.

When the post is viewed, they are converted to broken absolute-URI references within the /blog path. If the post is edited to have the correct absolute-URI reference, then they are no longer converted back to relative paths when the post is saved.

They are converted to incorrect absolute-URI references by the output utils url serializer. It looks like there is a known issue with this utility when using sites configured to run in a subdirectory.

I’ve tried working around this by removing references to the relativeToAbsolute function in the post serializer, but it didn’t seem to go as planned. The absolute-path reference I needed was displayed correctly, but a bunch of other stuff broke. I think I’ll give up on this for now.