joanq joanq - 3 months ago 28
Markdown Question

How to integrate UML diagrams into GitLab or GitHub

I want to publish some programming documentation I have in a public available repository. This documentation has formatted text, some UML diagrams, and a lot of code examples. I think that GitHub or GitLab are good places to publish this.

To publish the UML diagrams, I would like to have some easy way to keep them updated into the repository and visible as images in the wiki. I don't want to keep the diagrams in my computer (or on the cloud), edit them, generate an image, and then publish it every time.

Is there a way to put the diagrams in the repository (in PlantUML syntax would be ideal), link them in the markdown text, and make the images auto-update every time the diagram is updated?


After trying, I discovered the service to be slow and seemingly not up to the latest version of PlantUML.

I've found a different way that's not quite as straightforward, but it works via's server (in the cloud). As such, it should work anywhere you can hotlink to an image.

It exploits the !includeurl function and is essentially an indirection. The markdown file links to a PlantUML source that includes the diagram's source. This method allows modifying the source in GitHub, and any images in the GitHub markdown files will automatically update. But it requires a tricky step to create the URL to the indirection.

Diagram of how it works

  1. Get the URL to the raw PlantUML source, e.g., (using the example in the joanq's answer)
  2. Go to (or and create a one-line PlantUML source that uses the !includeurl URL-TO-RAW-PLANTUML-SOURCE-ON-GITHUB operation. Continuing with the example URL, the PlantUML (meta)source is:

  3. Copy the image URL from's image, e.g., and paste it into your GitHub markdown file. This URL won't change.

    ![PlantUML model](

Bonus: You can even get access to the SVG format by modifying the plantuml/png/ part of the URL to be plantuml/svg/ as follows

![PlantUML model](

Example on GitHub

Edit: Alternative with Proxy service

This way is significantly different and simpler than the answer above; it uses the PlantUML proxy service:

The GitHub markdown for this would be:

![alternative text](

This method suffers from not being able to specify the SVG format (it defaults to PNG), and it is perhaps not possible to work-around the caching bug mentioned in the comments.