Topic on Manual talk:How to make a MediaWiki skin

Nasirkhan (talkcontribs)

I need to add <meta name = "viewport" content = "width=device-width"> meta. Can you please tell me how can i configure my skin to add this meta on each page ?

Jdlrobson (talkcontribs)
Nasirkhan (talkcontribs)

"responsive": true makes a skin responsive, but does not add the meta tag, I am interested to know that.


even though it makes a skin responsive, but I need to add the viewport meta into the skin. I followed this approach earlier and found that Google Search Console marked the site with "Mobile Usability issue: Viewport not set". As a result thousand of my pages are marked with this issue.

For this reason, I mentioned the meta tag not asked to know how to make a skin responsive! Please help me to find the solution to this.

Jdlrobson (talkcontribs)

> "responsive": true makes a skin responsive, but does not add the meta tag, I am interested to know that.

Out of interest what do you think this option is doing?

> I followed this approach earlier and found that Google Search Console marked the site with "Mobile Usability issue: Viewport not set".

If this is not working for you, I suspect you are running an outdated version of MediaWiki. What version of MediaWiki are you running on your pages with the Google search console?

> For this reason, I mentioned the meta tag not asked to know how to make a skin responsive! Please help me to find the solution to this.

My answer is correct, I've left some pointers to code on the main branch.

Skin's have a method called isResponsive. This reads directly from the skin option you define in skin.json:

https://github.com/wikimedia/mediawiki/blob/master/includes/skins/Skin.php#L204

This skin option adds a viewport meta tag to the HTML. It doesn't do anything else at time of writing:

https://github.com/wikimedia/mediawiki/blob/master/includes/skins/Skin.php#L216

Nasirkhan (talkcontribs)

Thank you for the clarification. It is my bad that I did not cleared the cache of the page source and found that there is no meta available. Though I cleared the page cache and before checking the page source. This happened in a MediaWiki 1.37. I am sorry for this misunderstanding.


Getting the notice from the Google search console happened on a MediaWiki 1.35 wiki.


"responsive": true works. I think the SkinLabs generated skins and Example skin should have this as the default, I may add a pull request there soon.