Re: [nikola-discuss] Link to anchor in another post

16 views
Skip to first unread message

Chris Warrick

unread,
Apr 18, 2017, 1:43:29 PM4/18/17
to Nikola—Discuss
On 15 April 2017 at 18:48, Stephen Phillips <st...@scphillips.com> wrote:
> Hi,
>
> I would like to be able to link from one post to a subheading in another
> post using RST.
>
> I found out somewhere that you can link to a subheading in the same post by
> writing:
>
> `subheading name`_
>
> (though I cannot find the documentation now!). that works by turning it into
> an anchor link to "#the-subheading-name", as each subheading is marked by an
> ID element formed that way. I know you can link to a post by writing:
>
> :doc:`creating-a-theme` or
> :doc:`my other post <creating-a-theme>`
>
> But how can I link to the subheading from another post? I expected something
> like:
>
> :doc:`creating-a-theme#subheading-name` or
> :doc:`my other post anchor <creating-a-theme#subheading-name>`
>
> but they give the error "slug doesn't exist".
>
> For now I have linked explicitly using:
>
> `my other post anchor </posts/2015/05/creating-a-theme#subheading-name`_

Add a slash before #.

> but I thought there ought to be a better way.
>
> Am I missing something?
>
> Thanks,
> Stephen Phillips.

You aren’t missing anything: the `doc` directive does not support
linking to subheadings, and neither do magic links. Feel free to
create an issue on GitHub if you think we should support that
use-case.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
Reply all
Reply to author
Forward
0 new messages