Adding images to your notebook

You can add images to your Pluto notebook quite easily! But it is different from what you might be used to in Jupyter, Word, or Google Docs.

Method 1: Using imgur and Markdown

The easiest way to add images to your notebook is to upload the image to imgur.com (or a similar service), and then use the Markdown syntax to embed the image URL.

First, go to imgur.com and upload your image. (You donโ€™t need to create an account.) Now, click on the ..., and then โ€œGet Share Linksโ€.

Imgur share links

We want the URL that points directly to the image. It should end with .png, .jpg, or something similar. You can get it from the โ€œBBCodeโ€ option.

Imgur share options

This should give you a URL like this:

https://i.imgur.com/qHCI8RS.png

Using the image URL in Markdown

In Pluto, create a new cell. We will use the Markdown image syntax to embed the image.

md"""

![Description of the image](https://i.imgur.com/qHCI8RS.png)

"""
Imgur markdown

You can also use PlutoUI.Resource or HypertextLiteral.jl to have more control over how the image is displayed.

Method 2: Using an image from GitHub

If your image is stored in a repository on GitHub, you can use the Markdown syntax to embed the image URL.

First, go to the image on GitHub. Click on the ..., and then โ€œCopy permalinkโ€. Now you have a permalink, which means that the URL will keep working, even if the repository changes.

GitHub image, with a button to copy the permalink

This permalink looks like:

https://github.com/fonsp/fonsp.github.io/blob/b74c865b0292006af89496418c2c19f48517ca2e/img/doggoSmall.jpg

Now, you need to add ?raw=true to the end of the URL, to get a URL that points directly to the image. This looks like:

https://github.com/fonsp/fonsp.github.io/blob/b74c865b0292006af89496418c2c19f48517ca2e/img/doggoSmall.jpg?raw=true

Using the image URL in Markdown

In Pluto, create a new cell. We will use the Markdown image syntax to embed the image.

md"""

![Description of the image](https://github.com/fonsp/fonsp.github.io/blob/b74c865b0292006af89496418c2c19f48517ca2e/img/doggoSmall.jpg?raw=true)

"""

You can also use PlutoUI.Resource or HypertextLiteral.jl to have more control over how the image is displayed.

Method 3: Using a local image

You can also embed images from your computer in Pluto notebooks, but we want to issue a warning here. It is often a better idea to use images hosted online (like imgur or GitHub).

Warning

Embedding images from your computer means that the notebook will not work if you try to open it on a different computer.

Images in the same repository

A special case is when the image is in the same repository as the notebook. In this case, other people can also see the image, if they clone the repository and run the notebook that way.

But if people run the notebook directly (with Binder, or by running the file without downloading the full repository), the image will not work.

To embed an image from your computer, you can use the PlutoUI.LocalResource:

using PlutoUI
PlutoUI.LocalResource("../images/dogs.png")
Local image