How to use relative links to job artifacts?

Replace this template with your information

Describe your question in as much detail as possible:
A copy of the repository is here: cdwijs / markdown-test · GitLab
I have a CI/CD job that generates a .png file. I can embed that .png file in the file like this:


This works fine, but when the repository is forked, the still uses the diagrams from this repository, instead of the forked repositories, resulting is stale graphs that are no longer generated from the correct repository. Therefore I want to use relative links.

This does not result in a graph, just a link:


When I click he link, I see the link comes out like this:

When I put the working and the non-working link under each other, I see the non-working link has “main” extra in the middle: (working) (not working)

What is the correct way to relative link to the image?

  • What version are you on? Are you using self-managed or
    I have a self-managed version GitLab Community Edition 14.6.0

  • Add the CI configuration from .gitlab-ci.yml and other configuration if relevant (e.g. docker-compose.yml)
    See also cdwijs / markdown-test · GitLab

image: gcc


  stage: deploy
     - apt update && apt -y install doxygen graphviz
     - doxygen
     - ./html/dot_inline_dotgraph_1.png
#     - ./html/index.html

Thanks for taking the time to be thorough in your request, it really helps! :blush:

Hi @cdwijs

Maybe this is overkill, but if you need the exact URL of the project in the README, then I think you probably need a pipeline to insert it.

The predefined variable CI_PROJECT_URL can be used to get the text that you want, so you would just need a little job in the pipeilne to run sed (or similar) over the README file.