Extension talk:Add HTML Meta and Title

Using v 1.9 - Adds keywords & description, but not the title
Here: http://against-the-day.pynchonwiki.com/wiki/index.php?title=Hawaii

Here's the code I added to the top of the page:



See a problem? Thanks!
 * Yes there is a problem - if you manage to find the fix - submit the code here.

I changed MonoBook.php, so that the part is this:

text('pagetitle') ?>

So at least you get the page title in there and each page has a different title tag.

Title tags don't work mediawiki 1.11.1
Title tag, except others, doen't work on MediaWiki 1.11.1 Good Job Done!


 * Thanks! I've just tested the extension on a fresh 1.11.1 - it works fine - all of it. Give me a link to your wiki. Владимир Радуловски 02:14, 4 March 2008 (UTC)

v0.2 to v0.4
Hello, the download link points to the v0.2. May we get a link to the latest version? -- skiidoo 02:45, 13 March 2008 (UTC)
 * done. Владимир Радуловски 21:35, 23 April 2008 (UTC)

Small fix to v0.2
While we're on it, there's a small problem with the v0.2. In $wgExtensionCredits, the 'description' keys is: 'description'=>'Adds the  tag so you can add to the meta keywords and HTML-title of a wiki-page. If you are lazy just use the short version:  .', You should replace the < and > signs by the HTML entities &amp;lt; and &amp;gt; to prevent Special:Version to see its title redesigned by the extension. -- skiidoo 02:45, 13 March 2008 (UTC)
 * done with htmlspecialchars Владимир Радуловски 21:41, 23 April 2008 (UTC)

Multiple META keywords tags
This extension *adds* a new META tag, so the page turns to have two META keywords tags: the one generated by the core MediaWiki software, and the one generated by this extension. Is it possible to make it that the keywords are added to the core generated tag? -- skiidoo 02:45, 13 March 2008 (UTC)
 * If you have time and skill - do some research and try to find a way. I don't know how to add meta words in any other way than the addmeta method. -- Владимир Радуловски 21:43, 23 April 2008 (UTC)

with MW 1.12
Hi, I'm using MediaWiki 1.12 and I have a problem using this extension. It is showing the right title, but it is not adding neither the META keywords, nor the META description, when I'm reading the HTML generated file using Firebug. You can check on : http://www.socialopedia.org --Rmatt 21:51, 17 April 2008 (UTC)


 * I tried the extension on a 1.12 - worked fine . Maybe yours fails because of the french words or the apostrophes... With simple english it works, with bulgarian too. Maybe it is an issue with interfering extensions - there are alot on your wiki -- Владимир Радуловски 21:45, 23 April 2008 (UTC)

Template
Can this extension work into a template? --user
 * don't know - what exactly do you mean? Владимир Радуловски 22:28, 12 December 2008 (UTC)

#tag
How is the correct syntax to use this extension with #tag: ?


 * Did not understand your Q. What is a #tag? Владимир Радуловски 12:50, 7 January 2009 (UTC)

download link unavailable
The download link is down....?

Does anyone have another link, or can someone post the extension code into this article?

Error
i get "Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxx/domains/klusopedia.nl/public_html/mediawiki-1.15.1/extensions/Description/Description.php:10) in /home/xxxxxx/domains/klusopedia.nl/public_html/mediawiki-1.15.1/includes/WebResponse.php on line 16"

i also get this warning when trying to install other extensions like extension:Description. What to do? Please help!

Not working with PHP 5.3.0
This extension doesn't seem to work with the newest PHP version 5.3.0. Can that be fixed? It would be a pity if I can't use this great extension anymore. --Plati123 16:13, 13 August 2009 (UTC)

Duplications
Hello, what do you think about following:

// Adds meta tags without duplications. function addMetaTag($out, $name, $value) { if (!empty($out->mMetatags)) { $count = count($out->mMetatags); for ($i = 0; $i < $count; $i++) { if ($out->mMetatags[$i][0] == $name){ // Exists $out->mMetatags[$i][1] .= ", $value"; return; }		}        	}    $out->addMeta($name, $value); }

But it does not work with tags that are created by default.

Duplications
To fix default tags duplications, I'll move insertMeta function to BeforePageDisplay hook: //function insertMeta( $out, $text ) { function insertMeta( $out) {

# Extract meta keywords if (preg_match_all( '//m', //$text $out->mBodytext, $matches)===false   ) return true; ...   # Extract meta keywords if (preg_match_all( '//m', //$text, $out->mBodytext, $matches)===false   ) return true; and use addKeyword: # Merge keyword data into OutputPage as meta tags foreach ($data AS $item) { $content = @base64_decode($item); $content = htmlspecialchars($content, ENT_QUOTES); if ($content) { //$out->addMeta( 'keywords', $content ); //addMetaTag($out, 'keywords', $content ); $out->addKeyword( $content ); }   } [mailto:slsoft@bk.ru?Subject=SEO:Add_HTML_Meta_and_Title Simon Litt] 23 September 2009.

Download site not available & is there already a v0.5 ?
unfortunately, the whole website velko.org is down. from the drupal error message, I understand this is gonna last :-( Can anyone share the source code here ?

also, seeking for another download possibility, I came accross one site reporting it is using v0.5 of this extension, although only v0.4 is listed here. can someone comment on this ?

Thanks --Jhf2442 13:26, 6 November 2009 (UTC)

Velko domain used for a marketing company
I think the whole velko.org domain has been given away to a different company.

I found a copy of the original extension, and will post it on the main page.

--DonGiulio 18:07, 16 June 2010 (UTC)

Setting title does not seem to work with MW 1.16
I'm using the extension in MW 1.16. Debugging it, seems that $out->setHTMLTitle( $new_title ) does not work. Can anyone else confirm? --Toniher 17:03, 8 September 2010 (UTC)
 * Yes, that's true. I have the same problem with MW 1.16. Could someone find a fix? Laurent --13:06, 9 September 2010 (UTC)
 * Also confirmed here. The description and keyword tags seem to work, but the most important tag--the title tag--ain't takin' hold. Hope someone who's a more clever php hacker than I am will kindly fix and post. -Davydog 15:14, 19 November 2010 (UTC)
 * One line needs to be added to Add_HTML_Meta_and_Title.php. Right before
 * insert the following:
 * Also, if you prefer to replace the title instead of appending to it, replace
 * with
 * Also, if you prefer to replace the title instead of appending to it, replace
 * with
 * with


 * Works perfectly, thanks a lot! Cheers, --Till Kraemer 11:45, 7 February 2011 (UTC)
 * Yes, it works. BTW: removing the "&" before the $parser param of renderSEO function makes it work with php 5.3
 * --Superxain 10:00, 14 March 2011 (UTC)

works! nice...but no title change.
I used it at goodpayer-badpayer.info, and see that is has, indeed, added metatags for keywords and description, however, it did not alter the title tag (no big deal). I'm satisfied. Good stuff!

--Tony Baldwin 15:19, 1 April 2011 (UTC)

Does not allow magic word substitution
if I use for example:  the magic word is not substituted..

this page suggests a fix, which I was not able to make work.

Does anyone have a solution to this problem?

fix for mediawiki 1.18 in function setupSEOParserHooks
When I tried to use this extenion with MW 1.18 I got this error: Call to a member function addMessage on a non-object in /www/docs/wiki/extensions/Add_HTML_Meta_and_Title.php on line 30

In MW 1.17 the extension still worked, after changing &$parser to $parser in function renderSEO( $text, $params = array, $parser )

But the function $wgMessageCache->addMessage is already marked as deprecated in mw 1.17. In mw 1.18 it does not exist.

I modified the function like this:

function setupSEOParserHooks { global $wgParser; $wgParser->setHook( 'seo', 'renderSEO' ); }

and put the error message directly inside

function renderSEO( $text, $params = array, $parser ) { $msgSeo_empty_attr = 'Error: &lt;seo&gt; tag must contain at least one non-empty &quot;title&quot; or &quot;metak(eywords)&quot; or &quot;metad(escription)&quot; attribute.'; .... {return... wfMsgForContent($msgSeo_empty_attr). }

I am not sure whether this gives the error message correctly when and where needed, but at least the function works.

1.18 Code Changes
Can some one better explain the code changes above used for 1.18? If you could copy/paste the whole block of code modified instead of having fragments with ... between them it would be much appreciated so i can recreate your fix.

Thanks!

MW-1.19 support
A bit cleaned up version supporting 1.19 on github - https://github.com/MageSlayer/MW-MetaTitle

Errors with MW 1.15.1 (Call to undefined function...)
Hi,

the new "Extension:Add HTML Meta and Title" Version 0.7 dont' work in my private wiki. If I put text in my article page, i receive this error on a blan white page:


 * MediaWiki: 1.15.1
 * PHP: 5.4.45 (cgi-fcgi)
 * MySQL:5.5.40-log

How I can fix or which version should I use? Best regards


 * Hi,
 * go to Special:ExtensionDistributor/AddHTMLMetaAndTitle and choose the oldest version. the 1_24 should work on a Mw1.15...
 * Regards,
 * Dennisroczek (talk) 18:52, 16 December 2015 (UTC)


 * Hi Dennisroczek,
 * thanks for the fast support :)
 * I tried it, but I get always an error. I tested also a version, where it works, but only without article content. In this case, if I wrote something in de article, I received an other error (not remember), with only the it worked.

Update to extension registration
I've updated this extension to use. If anyone feels like reviewing my patch https://gerrit.wikimedia.org/r/#/c/384200/ that'd be great! :-) Thanks. Sam Wilson 04:38, 14 October 2017 (UTC)