Search code examples
mediawikimediawiki-templates

Mediawiki link within the page to a specific place, rather than a section


1. Question

If I code like the following, then I have a link within the page to a specific "section"

[[#SectionTitle|displayed text]]

But what if I want to have a link within the page to a place, I mean any place?

Sometimes I might want to directly refer to a part of the page that isn't at the start of a section.

2. What I tried

I tried something like this

[[#Foo|displayed text]]
{{anchor|Foo}}

This seemed to ask me to make a page Template:Anchor

So I copied the Template:Anchor page of wikipedia.

But Template:Anchor again seemed to ask to make some new page, because Template:Anchor only says

{{#invoke:anchor|main}}

So my attempt didn't work.


Solution

  • Use the following to create the anchor:

    <div id="NameOfAnchorHere">optional text</div>
    

    which can be referenced as:

    [[#NameOfAnchorHere| test]]
    

    More information about linking in MediaWiki can be found here