0

How to add HTML into the HTML tag for all MediaWiki web pages?

  • In /skins/mySkin/includes/mySkinTemplate.php I didn't find anything that does with <head>.

  • I found no global template file and I prefer not to use a hook for that.

How would you do it?

1
  • This is a programming issue and off topic for here. I would direct you to Stack Overflow but your question would not be allowed there either as it is written.
    – Rob
    Jun 21, 2019 at 0:01

1 Answer 1

1

In the end I used this JavaScript way to add HTML code to <head> for all pages via ?title=MediaWiki:Common.js:

var templateLiteral = [`
    <!-- HTML_CODE_COMES_HERE -->
`]

var head = document.querySelector("head");
head.innerHTML = templateLiteral;

I then checked a webpage and saw the code was added to HTML source.

4
  • Hello, I would be happy to know what's bad with the answer. If I was wrong in anything, I'd gladly remove it... This worked for me and made the relevant API recognize my site, hence I don't understand the down vote.
    – user58733
    Jun 22, 2019 at 13:04
  • Your whole question, and two others on this platform, are off topic and should have been closed. Webmasters is not about coding at all. Such questions belong on Stack Overflow instead. Why all three were not deleted immediately is completely bizarre to me but it happens often here. webmasters.stackexchange.com/help/on-topic
    – Rob
    Jun 23, 2019 at 11:34
  • "How do I add HTML into a tag" is never a marketing issue.
    – Rob
    Jun 23, 2019 at 16:31
  • Sorry, I confused with another question to which this issue is relevant (behind the scenes). I will delete what I wrote above and suggest comment deletion.
    – user58733
    Jun 23, 2019 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.