29

How to make an internal hyperlink in Sphinx documentation? I am using:

:role:`target`

But it is not working.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
ajax-ie
  • 293
  • 1
  • 4
  • 7

2 Answers2

33

Cross-referencing is done using a ref

:ref:`label-name`

You can provide your labels using:

.. _label-name:

See: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref

Roles are used to create custom interpreted text. See: http://docutils.sourceforge.net/docs/ref/rst/directives.html#role

Steffo
  • 305
  • 5
  • 13
pyfunc
  • 65,343
  • 15
  • 148
  • 136
3

In somewhere the heading is,

.. _HeaderTag:

Header
------

Ref to above header (may not the same file)

:ref:`HeaderTag`

# or with custom text
:ref:`custom header<HeaderTag>`
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Anh-Thi DINH
  • 1,845
  • 1
  • 23
  • 17