Issue #5 wontfix
Anonymous created an issue

In essence this is a feature that would allow for relative paths as well.

When including an asset (such as an image) in a post, the URL to the asset is not rewritten depending on the destination in the filesystem of the link location. If I include my top5 posts in /index.html, and route the individual posts to /{postname}/index.html, the link to the asset is wrong in either one of these pages. I suppose checking every src of href tag is required and needs to be corrected. In my opinion an important requirement for this kind of software, so it would be great if you can include this.

Comments (12)

  1. Anonymous

    True, but it only works with a properly configured web server. Not all hosts put your subdomain as root. Wouldn't you think this is a nice thing to have?

  2. Anonymous

    Seconded. Another option would be to add some base_url to every relative href/src tag. What do you think?

  3. Andrey Vlasovskikh repo owner

    You can set up a url value in your _config.yml and prepend it to URLs on your pages manually as {{ site.url }}. Yes, it could be quite tedious, but it's compatible with Jekyll.

    Another workaround is to write an Obraz plug-in that actually prepends this value to all relative URLs. See this blog post for more info on plug-ins. Note that the plug-in interface is considered experimental.

  4. Brent Huisman

    if you are interested, I 'solved' this as follows: 1) a plugin that adds to every page the depth in the filesystem: http://huisman.tk/plugins/#relativize.py

    2) use that in a layout file, that regexes each and every page in full ands updates href and src tag elements, like so:

    ---
    ---
    {{ content|regex( "(href|src)=[\"']/([^\"']*)[\"']" , '\\1="'+page.relpath+'\\2"' ) }}
    
  5. Andrey Vlasovskikh repo owner

    The "Jekyll-compatible" solution to this problem will be using absolute URLs in combination with and setting baseurl in _config.yml and using it in your hrefs for those servers that don't serve your content at the root URL.

    Having a custom plugin for relative URLs is also a good idea.

  6. Log in to comment