Allow Relative Links to Images Hosted in the Same Repository

peter.rebholz's Avatar


18 Nov, 2015 10:31 PM

When writing a README or other markdown document we may want to include some images. Most likely the images are also going to be contained within the repository (this is pretty common for documentation where an image can help illustrate something) so we should be able to refer to them with relative URLs. Unfortunately, RhodeCode uses a different URL pattern to serve the raw contents of the file (*/files/* when viewing a rendered markdown document and */raw/* when viewing a the raw contents of the file) so we can't really use relative links.

It would be nice if relative URLs embedded in markdown documents could properly fetch an image. It seems like the fix would be to use the Accept header to decide when to send the RhodeCode page or the raw contents. Bonus points if this also works in the landing page README ;-)

  1. Support Staff 1 Posted by Marcin Kuzminsk... on 19 Nov, 2015 12:10 AM

    Marcin Kuzminski's Avatar

    Hi Peter,

    Thanks for feedback as usual.

    To help me understand it better. Why a syntax like:

    .. image:: ../raw/7815000b63cb8bbb6da0753b672fb3f7e85a11fc/rhodecode/public/images/rhodecode-logo-white-216x60.png

    for rst format, and:

    ![Alt text](../raw/7815000b63cb8bbb6da0753b672fb3f7e85a11fc/rhodecode/public/images/rhodecode-logo-white-216x60.png)

    for markdown cannot be used in this case ?

  2. Support Staff 2 Posted by Marcin Kuzminsk... on 19 Nov, 2015 12:42 AM

    Marcin Kuzminski's Avatar


    sorry i have actually tested it on the inline comments/main comments.
    Infact inside the rendered images in files it;s not working. Let me investigate this.

  3. 3 Posted by peter.rebholz on 19 Nov, 2015 02:07 PM

    peter.rebholz's Avatar


    If I have a directory structure like:

    + images/
       + my-image.png

    What I'd like to be able to do inside of is refer those images relative to where is in the source tree. For example:

    ![alt text](./images/my-image.png)

    When viewing the from the repository landing page, this relative URL will result in a 404. When viewing the from the file browser the URLs will result in a 200 but the content will be the HTML page, not the raw file contents.

    Using URLs like this means that they will work outside of RhodeCode too; like when viewing with a Markdown viewer.

  4. Support Staff 4 Posted by Marcin Kuzminsk... on 25 Feb, 2017 10:37 PM

    Marcin Kuzminski's Avatar

    bumping this issue.

  5. Support Staff 5 Posted by Marcin Kuzminsk... on 25 Feb, 2017 10:39 PM

    Marcin Kuzminski's Avatar

    Ticket was backported to issue tracker: on 2017-02-25T22:39:56Z

  6. Marcin Kuzminski closed this discussion on 25 Feb, 2017 10:39 PM.

  7. Marcin Kuzminski re-opened this discussion on 13 Mar, 2017 04:52 PM

  8. Support Staff 6 Posted by Marcin Kuzminsk... on 13 Mar, 2017 04:52 PM

    Marcin Kuzminski's Avatar

    This is now implemented and will be part of 4.7 release.

  9. 7 Posted by jesse.kawell on 03 Aug, 2017 04:04 PM

    jesse.kawell's Avatar

    Is there a way to similarly do this for links to other Markdown files? Right now if I do a relative link to a .MD file (like Peter did with images above) clicking the link goes to the raw version of the file ("../raw/7815000b63cb8bbb6da0753b672fb3f7e85a11fc/"). Because it's written in Markdown though it is far more useful for it to load the file preview so you get the well-formatted display (basically linking to "../files/7815000b63cb8bbb6da0753b672fb3f7e85a11fc/" instead). Does that make sense?

  10. Support Staff 8 Posted by Marcin Kuzminsk... on 03 Aug, 2017 10:20 PM

    Marcin Kuzminski's Avatar

    Hi Jesse,

    This makes sense, i think a good option would be to allow rendering using a GET flag.

    file-1-rendered [file-1-rendered](./docs/

    Would use a rendered version of the file, what do you think about such solution ?

  11. Support Staff 9 Posted by Marcin Kuzminsk... on 04 Aug, 2017 10:43 AM

    Marcin Kuzminski's Avatar

    ON the second thought, i think links (not images/video) should always produce a link to not raw files, and the GET flag should be expose to force raw version.

    We'll add such change to the next release, so all relative links for RST/MD files would just work.

  12. 10 Posted by jesse.kawell on 04 Aug, 2017 02:28 PM

    jesse.kawell's Avatar

    I agree. Links to code files and such are nicer if they get the formatted/syntax-highlighted versions too. The flag would be nice for anyone that needs the old behavior for some reason. Thanks for you help! Looking forward to the updated release.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


17 Oct, 2018 03:22 PM
15 Oct, 2018 05:20 AM
03 Oct, 2018 01:16 PM
01 Oct, 2018 08:41 AM
28 Sep, 2018 10:12 AM
26 Sep, 2018 04:34 AM