Jump to content

Editing sidebar

From Wikven

The navigation sidebar is configured the same way as on MediaWiki, through the MediaWiki:Sidebar system message. Create a MediaWiki/Sidebar.wikitext file in your source directory, alongside your other pages.

Each top-level * line is a heading, and each ** line below it is a link written as page|label. Headings and labels are looked up as system messages first and only fall back to the literal text when no such message exists, so mainpage and mainpage-description resolve to the main page and its label. Write your own as message names too, because a message is what makes a label translatable: the wording in your source language goes in MediaWiki/Sidebar-docs.wikitext and each translation in MediaWiki/Sidebar-docs/<language>.wikitext, next to your other pages, the way every other translated page is named. A sidebar then reads like this:

* navigation
** mainpage|mainpage-description
* sidebar-docs
** Getting Started|sidebar-getting-started
** Images|sidebar-images
* sidebar-references
** Configuration|sidebar-configuration

A target is looked up as a message before it is read as a page name, the same way a label is, and MediaWiki drops an entry whose message says - — that is how it turns one of its own default entries off. So a target that happens to share a name with such a message leaves the sidebar without a word about it. The one worth knowing is licenses, the upload form's list of licence options, which MediaWiki defines as -: an entry for a page called Licenses is dropped when the target is written plainly. Write it with a leading colon, as :Licenses, to name the page itself and skip the lookup. The Special:MyLanguage/ prefix below does the same, which is why the example under it needs no colon.

Linking on a translated site

A target names one page, so an entry leads to that page and no other: a reader on a translated page follows the sidebar back into the source language. Write the target as Special:MyLanguage/Page, the spelling MediaWiki's own wikis use, and the build resolves it per page instead: on a page in a given language the entry links to that language's translation of the target, and to the source page where there is none. The prefix also keeps a target out of the message lookup above, so Licenses needs no colon here:

* navigation
** mainpage|mainpage-description
* sidebar-docs
** Special:MyLanguage/Getting Started|sidebar-getting-started
** Special:MyLanguage/Images|sidebar-images
* sidebar-references
** Special:MyLanguage/Licenses|sidebar-licenses

The spelling is a wiki's; the rule behind it is not. On a wiki, that special page redirects at request time to the reader's own interface language, whatever page the link sat on, so two readers of one page follow the same entry to different translations. A static export has no request and no reader to ask, so the build settles each link once, by the language of the page holding it, and every reader of that page follows it to the same place.

The main page keeps its plain mainpage entry, because that target is a message: the prefix goes in the message instead. Write Special:MyLanguage/index in MediaWiki/Mainpage.wikitext (index being whatever WikvenMainPage names), as Meta-Wiki does. Every skin points its logo at that same message, so the logo follows the reader's language too. The cost is that the wiki stops recognising the page as its main page: the page title shows in the browser tab, and MinervaNeue leaves out its main-page styling.

What is removed

Some default sidebar blocks need a live wiki, so Wikven drops them from the static export: the toolbox (What links here, Special pages, Printable version, and so on) and the search box. The navigation blocks you define in MediaWiki:Sidebar are kept as written.

The page you are on

Nothing marks the entry for the page being read: it stays an ordinary link to where the reader already is. That is MediaWiki's own behaviour rather than anything the export changes. Every sidebar item is built with its active flag set to false and nothing sets it otherwise, so the sidebar never compares an entry with the page around it — the tabs above an article do make that comparison, and the sidebar alone skips it. Writing the target as Special:MyLanguage/Page changes nothing here either way.

A site that wants it marked can do that in its own JavaScript, since the reader's browser knows which page it is on: for each sidebar link that resolves to the page being read, drop the href and set aria-current="page". A link with no href is no longer one — it cannot be clicked or focused, and it gives up the link colour by itself — and aria-current is what names the entry for a reader who is not looking at it. This site does it in a gadget, MediaWiki:Gadget-SidebarCurrentPage.js.

See also