DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:htmlmetatags

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:htmlmetatags [2016-07-06 10:48] – [Improve completeness of accepted metatags] 88.160.29.72plugin:htmlmetatags [2023-10-31 00:08] (current) Klap-in
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Adds some meta tags to the html header (e.g. keywords, description or any others)+description: Adds some (open graph) meta tags to the html header (e.g. keywords, description or any others)
 author     : Soft2C.de author     : Soft2C.de
 email      : info@soft2c.de email      : info@soft2c.de
 type       : Action, Syntax type       : Action, Syntax
-lastupdate : 2015-05-19 +lastupdate : 2023-06-12 
-compatible : 2012-10-13 "Adora Belle",2013-05-10a "Weatherwax",Release 2013-12-08 "Binky",Release 2014-05-05e "Ponder Stibbons",Release 2014-09-29d "Hrun"2015-08-10 "Detritus" +compatible : DetritusElenor of TsortFrusterick MannersGreeboHogfatherIgor, Jack Jackrum 
-tags       : html meta search seo info +depends    :  
-  +conflicts  :  
-downloadurlhttp://www.soft2c.de/pub/htmlmetatags.zip+similar    : socialcards 
 +tags       : html meta search seo info open graph semantic 
 + 
 +bugtracker https://github.com/heikoS2C/htmlmetatags/issues 
 +sourcerepo : https://github.com/heikoS2C/htmlmetatags 
 +downloadurl: https://github.com/heikoS2C/htmlmetatags/archive/master.zip  
 donationurl: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GN27JNRYKUYTG donationurl: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GN27JNRYKUYTG
 ---- ----
Line 16: Line 21:
 ===== Description ===== ===== Description =====
  
-This plugin enriches the html page with all meta tags what you wont, e.g. keywords, description and any others.+This plugin enriches the html page with all meta tags what you want, e.g. keywords, description and any others.
 Some meta information are very usefull for web crawlers for indexing and categorizing the page. Some meta information are very usefull for web crawlers for indexing and categorizing the page.
 +
 +Extends with V2.0:
 +This version allow you to add :
 +  * open graph metatags like //og:description//, //og:image//...
 +  * link to media file. tags must start with //media-//
 +    * //media-og:image=(:wiki:image.jpg)//
 +  * multiple calls to htmlmetatags all values will be added
 +
 +**Note:** The Initial version of this plugIn is not compatible to the new V2.xy. The difference of attribute to value splitter is changed from ':' to '='. \\
 +
 +<code>
 +  {{htmlmetatags>metatag-keywords=(values) metatag-og:description=(open graph description.)}}
 +</code>
 +
 +**Note:** Linebreaks can add inside the <nowiki>{{ }}</nowiki> without any trouble.
 +<code>
 +  {{htmlmetatags>metatag-keywords=(values)
 +    metatag-og:description=(open graph description.)
 +  }}
 +</code>
  
 ===== Syntax ===== ===== Syntax =====
  
-With the string ''%%{{htmlmetatags>...}}%%'' on the page level you activates the plugin. The leading string "metatag-" marks a tag for the web site. After this leading string followed the key from tag. In ''%%:(...)%%'' write the value of the tag.+With the string ''%%{{htmlmetatags>...}}%%'' on the page level you activate the plugin. The leading string "metatag-" marks a tag for the web site. After this leading string followed the key from tag. In ''%%=(...)%%'' write the value of the tag.
  
 Also, the plugin is on page level. Also, the plugin is on page level.
Line 28: Line 53:
  
 <code> <code>
-{{htmlmetatags>metatag-mytag:(some usefull text)}}+{{htmlmetatags>metatag-mytag=(some usefull text)}}
 </code> </code>
  
-The meta tag: //mytag// is any word. This word is the name of the new meta tag, e.g. keyword. Followed on this name is to write '':'' with ''%%('...')%%''. This brackets contains the text required for the value of the new meta tag.+The meta tag: //mytag// is any word. This word is the name of the new meta tag, e.g. keyword. Followed on this name is to write ''='' with ''%%('...')%%''. This brackets contains the text required for the value of the new meta tag.
  
 You can write more than once meta tag on the page separate by space. You can write more than once meta tag on the page separate by space.
  
 <code> <code>
-{{htmlmetatags>metatag-robots:() metatag-keywords:(apfel,bananne,birne) metatag-description:(Allgemeiner Obstbauer)}}+{{htmlmetatags>metatag-robots=()  
 +metatag-keywords=(apfel,bananne,birne)  
 +metatag-description=(Allgemeiner Obstbauer) 
 +metatag-media-og:image=(:wiki:image.jpg) 
 +metatag-og:description=(anything else) 
 +metatag-og:any=(anything else 2) 
 +}} 
 </code> </code>
  
Line 42: Line 74:
  
 <code html> <code html>
-<meta name="robots" content=""/>+<meta name="robots" content="noindex,nofollow"/>
 <meta name="keywords" content="apfel,bananne,birne"/> <meta name="keywords" content="apfel,bananne,birne"/>
-<meta name="description" content="Allgemeiner Obstbauer."/>+<meta name="description" content="Allgemeiner Obstbauer"/> 
 +<meta property="og:image" content="http://localhost/lib/exe/fetch.php?media=wiki:image.jpg"/> 
 +<meta property="og:description" content="anything else"/> 
 +<meta property="og:any" content="anything else 2"/>
 </code> </code>
  
 ===== Installation ===== ===== Installation =====
  
-Download the plugin at [[http://www.soft2c.de/pub/htmlmetatags.zip|htmlmetatags.zip]] and extract the zip file to the plugin folder on your dokuwiki.+Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
-===== Change Log =====+Download the plugin at [[https://github.com/heikoS2C/htmlmetatags/archive/master.zip|htmlmetatags-master.zip]] and extract the zip file to the plugin folder on your dokuwiki.
  
-  * **2015-05-27** Initial release +===== Further Informtions ===== 
-  * **2016-04-22** Change the date for "last Update"+This section explains some usefully tips for using the plugin. Check your generated html code for the right meta tag and optimize it with this plugin. Crawlers (like google) collect their data by reading the the meta tag and then by the content. Of curse every crawler uses own algorithm for indexing the web pages.
  
-===== FAQ =====+  * [[https://wiki.selfhtml.org/wiki/HTML/Kopfdaten/meta| baselines for html meta tags]] 
 +  * [[http://ogp.me| description for The Open Graph protocol]] 
 +  * [[http://www.suchradar.de/magazin/archiv/2013/4-2013/html-verbesserungen.php|tips for optimization your web page]]
  
-===== Discussion ===== 
  
-The date in plugin.info.txt is not correct! Maybe a typo, but dw says "update available".+===== Change Log =====
  
-==== Improve completeness of accepted metatags ====+{{rss>https://github.com/heikoS2C/htmlmetatags/commits/master.atom date}}
  
-This code allow you to add : +  **2017-04-24** V2.2 make it compatible wit PHP 7 
-  open graph metatags like //og:description//, //og:image//..+  * **2017-02-08** V2.1 when no metadata is available then set/add this on page (with the given keys via this plugin) 
-  * link to media filetags must start with //media-/+  **2016-07-12** V2.0 add handling for open graph metatags (Eric Maeker <eric@maeker.fr>
-    //media-og:image=(:wiki:image.jpg)// +  * **2016-04-22** Change the date for "last Update" 
-  * multiple calls to htmlmetatags all values will be added+  * **2015-05-27** Initial release
  
-Syntax is improved to (note the difference of attribute to value splitter from : to =+===== FAQ =====
-  {{htmlmetatags>metatag-keywords=(values) metatag-og:description=(open graph description.)}}+
  
-Note: you can add linebreaks inside the <nowiki>{{ }}</nowiki> without any trouble. +===== Discussion =====
-  {{htmlmetatags>metatag-keywords=(values) +
-    metatag-og:description=(open graph description.) +
-  }}+
  
-To implement this, replace these two functions in syntax.php with the following code. +==== Feature Request: Define OpenGraph image directly in an image tag ====
-<code php> +
-    /** +
-     * Based on the code by Heiko Heinz +
-     * Modifications by Eric Maeker, 2016, BSD licence +
-     */+
  
-    /** +**Proposal:** In the spirit of [[wp>Don't repeat yourself]] I'd prefer to not have a "metadata-container" in which I define a "metatag-media-ogattribute and define its image filepath/link only to later in the content area again having an image with its filepath placed but instead directly in my image of choice say "This is my openGraph image for that page" by a markup like this %%{{wiki:dokuwiki-128.png?og}}%%. If I have multiple images on a pageI could simply remove the og-tag from one and add it to another one. But the other method should be keptbecause it allows advanced features such as using images which are not present in the page content.
-     Handle matches of the htmlmetatags syntax +
-     * +
-     * @param string $match The match of the syntax +
-     * @param int    $state The state of the handler +
-     * @param int    $pos The position in the document +
-     * @param Doku_Handler    $handler The handler +
-     * @return array Data for the renderer +
-     */ +
-    public function handle($match, $state, $pos, Doku_Handler &$handler){ +
-        // Remove all linefeeds before parsing attributes +
-        $match = str_replace(PHP_EOL,"",$match); +
-        // Explode match into attributes array using 'metatag-' as mask +
-        return explode("metatag-", preg_replace("/{{htmlmetatags>(.*?)}}/","\\1"$match)); +
-    }+
  
-    /** +**In general:** Thanks for providing his! Am currently researching which CMS to choose for my portfolio and am seriously considering DokuWiki as I love it's simplicityOne thing which held me back was not having OpenGraph support which is such convenience for URL sharing in any media (messengerssocial media). If that works out with your plugingreat
-     * Render xhtml output or metadata + 
-     * +--- [[user>porg|porg]] //2021-06-21 20:09//
-     * usage{{htmlmetatags>metatag-keywords:(apfel,bananne,birne) metatag-description:(Allgemeiner Obstbauer)}} +
-     @param string         $mode      Renderer mode (supported modes: xhtml) +
-     @param Doku_Renderer  $renderer  The renderer +
-     * @param array          $data      The data from the handler() function +
-     * @return bool If rendering was successful. +
-     */ +
-    public function render($mode, Doku_Renderer &$renderer, $data) { +
-     +
-    global $ID; +
-     +
-        switch ($mode) { +
-          case 'metadata'+
-              /*  +
-               * e.g. +
-               * data[0]="keywords=(apfel, bananne, birne) " +
-               * data[1]="og:description=Allgemeiner Obstbauer" +
-               */ +
-              for ($i=0;$i<sizeof($data);$i++) { +
-                 $mt = explode("=", $data[$i]); +
-                 $size = sizeof($mt); +
-                  +
-                 // If attributes as value +
-                 if(sizeof($mt)==2){ +
-                    $name = trim($mt[0]); +
-                    $content = trim(preg_replace("/\((.*?)\)\s*$/","\\1",$mt[1])); +
-                    // Test if attribute name is a media files and get media file absolute URL +
-                    if (substr($name0, 6) === 'media-'+
-                        $name = substr($name6); +
-                        $content = ml($content, '', true, '&amp;', true); +
-                    } +
-                    // Send result to renderer +
-                    if (!empty($content)) { +
-                      if ($name == "keywords") { +
-                        if (!empty($renderer->meta['htmlmetatags'][$name])) +
-                          $renderer->meta["htmlmetatags"][$name] .= ', '.$content; +
-                        else +
-                          $renderer->meta["htmlmetatags"][$name] .= $content; +
-                      } +
-                      else +
-                        $renderer->meta["htmlmetatags"][$name.= $content; +
-                    } +
-                 } +
-              } +
-              return true; +
-        } +
-         +
-        return false; +
-    } +
-</code>+
  
 +==== Thanks by Eivind  ====
  
 +Thanks for a really helpful plugin! I have one issue: Open Graph allows for several images to be specified, but this plugin smacks them together in the same meta content.  --- [[user>molefunk|Eivind]] //2016-11-28 21:48//
plugin/htmlmetatags.1467794931.txt.gz · Last modified: 2016-07-06 10:48 by 88.160.29.72

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki