Page MenuHomePhabricator

Publicly visible section edit buttons are indexable by search engines
Open, Needs TriagePublicBUG REPORT

Description

For anonymous contributions MediaWiki has the option the publicly show "edit sections" (see https://www.mediawiki.org/wiki/Manual:Section_editing), even for anonymous users. This has benefits for higher participation.

A major drawback however is that "edit sections" have an edit button that displays "edit" as text. This is picked up and indexed by search engines and leads to misleading search results.

Example search site:mediawiki.org "Enabling and disabling section links" on Google. There is a superfluous edit there in the search result after the headline text ends.

Find some way to exclude the "edit" word from search engine indexing without making them invisible to users using the wiki.


We developed a Template:GoogleOff which makes use of mediawiki-extension-widgets.

{{#if: {{{nosnippet|}}}
|
<div data-nosnippet>{{{content}}}</div>
|
<div class="robots-nocontent" data-nosnippet>{{#widget:HtmlComment|content=googleoff: index}}{{#widget:HtmlComment|content=noindex}}{{{content}}}{{#widget:HtmlComment|content=/noindex}}{{#widget:HtmlComment|content=googleon: index}}</div>
}}

usage:

{{GoogleOff|content=
content goes here
}}

That template generally works well for wiki content but of course cannot be used to hide the "edit" word from search engines.

The rendered HTML looks as follows (added newlines for easier reading):

<div
class="robots-nocontent"
data-nosnippet=""
>
<!--googleoff: index-->
<!--noindex-->
test content here
<!--/noindex-->
<!--googleon: index-->
</div>

It's based on our reading of stackexchange on how to prevent search engines from indexing specific parts of a website and works well so far with major engines. It combines the required HTML markup required for different search engines since this doesn't seem to be standardized.