create new tag
, view all tags


Insert HTML "meta name" entries into html header


This plugin exists for one reason, and one reason only: To get <meta> tags into the html header. Why? It turns out that some search engines won't index a page without "proper" meta tags. Other search engines give better results with meta tags. Unfortunately, TWiki didn't have a good way to do this. %HTTP_EQUIV_ON_VIEW% isn't really up to the task, as it only allows you to specify one thing.

Syntax Rules

  • %HTMLMETA{[name=]"meta name" content="meta content" [visibility="number"]}%
    • This variable follows the standard TWiki syntax: The first parameter's name is optional.
    • If "meta name" is not unique, the last one specified wins!
    • visibility is optional. If not given, the VISIBILITY configuration variable will be used; otherwise, the value of this parameter will be added to the value of the VISIBILITY configration variable. If the resulting value is > 0, then the %HTMLMETA% variable will be displayed in the topic's body. Otherwise, and by default, it will not be.


  • %HTMLMETA{name="keywords" content="TWiki,plugins,metatags"}% Set meta keywords for this page.
  • %HTMLMETA{"description" content="This page describes the HtmlMeta plugin"}% Set meta description for this page. Name is defaulted.
  • %HTMLMETA{name="copyright" content="&copy;2006" visibility="1"}% Set copyright for this page. The variable will also display on the page.

Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %NEWPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Insert HTML "meta name" entries into html header

  • To get debug messages (in data/debug.txt), set DEBUG to 1. Default: 0
    • Set DEBUG = 0

  • Master control on visibility in topic of HTMLMETA variable (integer: Added to VISIBILITY in HTMLMETA, if present. If total > 0, show variable, otherwise, don't):
    • Set VISIBILITY = 0

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.

  • Download the ZIP file from the plugin web (see below)
  • Unzip HtmlMetaPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/HtmlMetaPlugin.txt Plugin topic
    lib/TWiki/Plugins/HtmlMetaPlugin.pm Plugin Perl module
  • Configure the Plugin:
    • Run the configure script to enable the plugin
    • Change the plugin settings as needed
  • Test if the installation was successful:
    • Since this plugin creates HTML Metadata in the <head> section, you have to view source to tell if it worked. If so, it will look something like:
       <meta name="keywords" content="TWiki wabbit" />
  • This will be quite a ways down in the source!
  • Here are a bunch of examples, some good, some not. Note that by default, many of them do not show up in the topic when the plugin is enabled, so I've listed each one twice: Once simulated, once real. If the simulated one would not show up by default, it is in italics
  • This one is good, but invisible by default:
    %HTMLMETA{name="keywords" content="TWiki"}%
    %HTMLMETA{name="keywords" content="TWiki"}%
  • This one is, too
    %HTMLMETA{name="description" content="It's all about TWiki"}%
    %HTMLMETA{name="description" content="It's all about TWiki"}%
  • This one has no content:
    %HTMLMETA{name="nocontent"}% - ERROR (HtmlMetaPlugin::_HTMLMETATAG): meta content not defined.
  • I've been through the desert on an HTMLMETA with no name:
    %HTMLMETA{content="no name"}% - ERROR (HtmlMetaPlugin::_HTMLMETATAG): meta name not defined.
    %HTMLMETA{content="no name"}%
  • This one is ok, uses default for name, but invisible by default:
    %HTMLMETA{"default" content="default name"}%
    %HTMLMETA{"default" content="default name"}%
  • This one has a bad name:
    %HTMLMETA{name="1Evil1" content="Doesn't start with a letter"}% - ERROR (HtmlMetaPlugin::_HTMLMETATAG): meta name has invalid characters.
    %HTMLMETA{name="1Evil1" content="Doesn't start with a letter"}%
  • A good name is to be desired, this one doesn't have one:
    %HTMLMETA{name="" content="Has html in it"}% - ERROR (HtmlMetaPlugin::_HTMLMETATAG): meta name has invalid characters.
    %HTMLMETA{name="" content="Has html in it"}%
  • This one has html in the content, should be escaped, but invisible by default:
    %HTMLMETA{name="ok1" content=""}%
    %HTMLMETA{name="ok1" content=""}%
  • This one has a non-character entity:
    %HTMLMETA{name="bad3" content=" "}% - ERROR (HtmlMetaPlugin::_HTMLMETATAG): meta content cannot contain non-character entities.
    %HTMLMETA{name="bad3" content=" "}%
  • This one has a hex non-character entity:
    %HTMLMETA{name="bad4" content=" "}% - ERROR (HtmlMetaPlugin::_HTMLMETATAG): meta content cannot contain non-character entities.
    %HTMLMETA{name="bad4" content=" "}%
  • This one has an extended character, which is ok, but invisible by default:
    %HTMLMETA{name="ok2" content="seņora"}%
    %HTMLMETA{name="ok2" content="seņora"}%
  • This one has a (character) entity, which is ok, but invisible by default:
    %HTMLMETA{name="ok3" content="©2006"}%
    %HTMLMETA{name="ok3" content="©2006"}%
  • This one has a ^G, which is not ok:
    %HTMLMETA{name="bad5" content=""}% - ERROR (HtmlMetaPlugin::_HTMLMETATAG): meta content cannot contain non-characters.
    %HTMLMETA{name="bad5" content=""}%
  • This one has bad visibility, so you can't see it in the header:
    %HTMLMETA{name="bad6" content="bad visibility" visibility="yes"}% - ERROR (HtmlMetaPlugin::_HTMLMETATAG): visibility must be a number.
    %HTMLMETA{name="bad6" content="bad visibility" visibility="yes"}%
  • This one has positive visibility, so you should see it:
    %HTMLMETA{name="ok4" content="positive visibility" visibility="1"}%
    %HTMLMETA{name="ok4" content="positive visibility" visibility="1"}%
  • If I was invisible...This one has negative visibility, so you shouldn't see it:
    %HTMLMETA{name="ok5" content="negative visibility" visibility="-1"}%
    %HTMLMETA{name="ok5" content="negative visibility" visibility="-1"}%
  • This one is good, but invisible by default. It is also has a duplicate name, so it is used, not the first one:
    %HTMLMETA{name="keywords" content="TWiki wabbit"}%
    %HTMLMETA{name="keywords" content="TWiki wabbit"}%

Plugin Info

Plugin Author: TWiki:Main.DougClaar
Copyright: © 2006, TWiki:Main.DougClaar
© 2006-2010 TWiki:TWiki/TWikiContributor
License: GPL (GNU General Public License)
Plugin Version: 2010-11-09 (V1.1)
Change History:  
2010-11-09: Doc improvements
2006-05-09: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
Benchmarks: GoodStyle 100%, FormattedSearch 100%, HtmlMetaPlugin 100%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/HtmlMetaPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/HtmlMetaPluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/HtmlMetaPluginAppraisal

Related Topics: TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 HtmlMetaPlugin.md5 r1 manage 0.2 K 2010-11-09 - 08:24 PeterThoeny  
Compressed Zip archivetgz HtmlMetaPlugin.tgz r1 manage 6.9 K 2010-11-09 - 08:24 PeterThoeny  
Compressed Zip archivezip HtmlMetaPlugin.zip r2 r1 manage 8.8 K 2010-11-09 - 08:24 PeterThoeny  
Unknown file formatEXT HtmlMetaPlugin_installer r1 manage 3.4 K 2010-11-09 - 08:24 PeterThoeny  
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2013-10-16 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.