Question

How I can customize headerlink in sphinx?

.. page.html

page
====

My header
______

My header resolve to link http://example.com/page.html#my-header

How to get http://example.com/page.html#my-custom-headerlink ?

Was it helpful?

Solution

You can reference a link with the following format:

page
====

`My Header <http://example.com/page.html#my-custom-headerlink>`_
----------------------------------------------------------------

or

`My Header <page.html#my-custom-headerlink>`_
----------------------------------------------------------------

You can also reference it like:

`my-header`_
--------------

.. _my-header: http://example.com/page.html#my-custom-headerlink

Using raw html you can have more control including control over the headerlink, however you lose it rendering in the toc.

.. raw:: html

    <div class="section" id="my-custom-headerlink">
    <h2><a class="reference external" href="index.html#my-custom-headerlink">My Header</a>
    <a class="headerlink" href="#my-custom-headerlink" title="Permalink to this headline">¶</a></h2>
    </div>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top