Relative URL in RSS feed

Since I chose to mix content and static files, I can use relative URLS for files inside my posts. For an image, I can only use the name of the file, like this :

[!](img-name.jpg)

I really like this simple way, but I didn’t think of something. In the RSS feed, I need to have absolute URL everywhere. Otherwise, it won’t work for the readers…

Is there a way to do so ? I noticed the relative URLs I’m using for internal links are working fine, so maybe this is a bug for images ?

Thanks !

OK, the issue is not relative URL, it’s that hugo doesn’t know it’s a URL. I suppose it needs a / somewhere in the URL, but I can’t do that the way I organized everything (image files and content file in the same place).

I don’t know if there’s an easy fix for that ?

I rewrote the “absurlizer” a while ago

so it recognises

href="/…“
src=”/…"
and the same with ‘…’ (in the XML case encoded entities).

And then srcset.

I’m not seeing a change coming in your direction on this anytime soon in the current model. The fix is to use URLs relative to context root. @spf13 is, however, thinking hard about a scheme where post and media are bundled together – and in that scenario he will have to come up with a good solution to this.

Well, in HTML, I have src="…" for images.

So it should work… or am I misunderstanding entirely your answer ?

EDIT : Also I don’t understand the URL relative to context root part. If you could help me on this. :slight_smile:

Yes.

src="…"

is not

src="/…"

If someone could do a proper analytic of the consequences of changing this to allow for your pattern, then it is an easy change. But also do think about the guy trying to generate 600K pages in 60 seconds.

Yes, I follow this thread with great interest. :slight_smile:

I guess I have two options then :

  • Find a way to generate absolute URLs and replace every image URL
  • Or do an import from WordPress again and keep the wp-content folder structure in order to duplicate this structure in /static/.

The last option is simpler and I guess I’ll be able to have quicker generation time for my blog. But I would loose the conveniency of having everything in one place, the content and the files associated with it.

Yes, as I said – I can change it if enough people say “yea, that will not break anything …” – then I can say I told you so.

I think I’ll stick to my actual system, and manually create absolute URLs for the articles needed by the RSS feed. After all, I only need to change 10 posts, everything else doesn’t matter (in my case).

And from now on, I’ll use absolute URLs in new posts.