Page MenuHomePhabricator

Retain section anchor in URL when clicking "Permanent link" link in the sidebar
Open, Needs TriagePublic


It would be nice if the section anchor in a URL was retained when clicking the "Permanent link" link in the sidebar of a MediaWiki page.

Currently if I'm visiting a URL such as in my Web browser and I click "Permanent link", I'll be taken to But I very often want the URL to be instead. I end up needing to click the link in the table of contents box to get the anchor back after clicking "Permanent link". This is somewhat annoying behavior.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 23 2019, 7:43 AM

There is probably a bad work around, but if the url contains # (meaning that a section is linked to) copy that from the current url and append it to the permalink. I can make that as an on-wiki script in the meanwhile if there is a better way to do it in PHP

@MZMcBride on-wiki script:

$(document).ready( function () {
    $('#t-permalink > a').each( 
        function() {
            this.href = 'javascript:window.permaLinkSection("' + this.href + '")';
} );
window.permaLinkSection= function( href ){
    var section = window.location.href.match(/#.*$/);
    if ( section && section[0] ) {
    	href = href + section[0];
    location.href = href;

if (understandably) this ticket isn't actioned soon, I may propose this as a gadget