HtmlMetaPlugin
Insert HTML "meta name" entries into html header
Introduction
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.
Examples
- %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="©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 %SYSTEMWEB%.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
- 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):
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:
- 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.
%HTMLMETA{name="nocontent"}%
- 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
Related Topics: %SYSTEMWEB%.TWikiPlugins, %SYSTEMWEB%.DeveloperDocumentationCategory, %SYSTEMWEB%.AdminDocumentationCategory, %SYSTEMWEB%.TWikiPreferences
to top
TWiki.HtmlMeta moved from TWiki.HtmlHead on 09 May 2006 - 21:10 by DougClaar?