Search code examples
python-sphinxrestructuredtext

:ref: link not giving link


Inside addCompanies.rst I have

Add Companies
=============

:ref: _my-reference-label:

adding
-----

ahdlkasdflk
This documentation will help you to add homes.

Now I am trying to link the file from another file change.rst in the same directory

Change company
=============

* How to add new company ? my-reference-label_

But the my-reference-label which I wanted to be a link is not producing any link.

What might be the problem here? Also what if I want to link the file from another directory file ?


Solution

  • The syntax you use above appears to be a non-sensical confusion of valid link syntax. You have the syntax for cross-referencing arbitrary links incorrect. This should remedy it and will work between files.

    addCompanies.rst

    Add Companies
    =============
    
    .. _my-reference-label:
    
    adding
    ------
    

    change.rst

    Change company
    ==============
    
    * How to add new company ? :ref:`my-reference-label`
    

    Also make sure that the underlines match the length of their text.