Search code examples
python-sphinxrestructuredtext

RST Sphinx - add hyperlink to internal image


How to add hyperlink to INTERNAL image in RST for sphinx? I want to have something like it:

Examples: 1, 2, 3, 4, 5

and then when i click on 1 i want it to move to imgs/1.png etc. I was trying to use ::image: imgs/1.png but that just renders picture and then when i am trying to:

Examples: 1_
:: _1: ../_images/1.png 

it doesn't copy the picture, so how do i combine them both? so i got a copied image that i can use as a hyperlink?


Solution

  • If I understand your question correctly, you want to click 1, and the web browser jumps to the referenced image.

    First set up the targets using the name attribute.

    .. image:: ../_images/1.png
        :name: 1
    
    .. image:: ../_images/2.png
        :name: 2
    

    Then reference the targets.

    Examples: `1`_, `2`_