[pmwiki-users] add meta tags to html - how to?

Patrick R. Michaud pmichaud at pobox.com
Fri Aug 25 14:11:31 CDT 2006


On 8/16/06, Tegan Dowling <tmdowling at gmail.com> wrote:
> On 8/16/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> > On Wed, Aug 16, 2006 at 11:27:06AM +0200, Moni Kellermann wrote:
> > > Hi everybody,
> > >
> > > how can I add some meta tags to all of the pages in a way that I can
> > > keep that code in case I upgrade?
> >
> > If you want to add keywords or descriptions to individual
> > pages, you can just use the (:keywords:) and (:description:)
> > markups.
> >
> > If you want to add meta tags for the entire site, then
> > use the $HTMLHeaderFmt array:
> >
> >     $HTMLHeaderFmt[] = "<meta name='keywords' content='special' />";
>
> This topic needs more documentation.  I'm pretty sure I'm not the
> person to provide it, though:
>
> That $HTMLHeaderFmt[] goes in config.php, right?

Yes -- it can also go into per-group or per-page customizations.

> Can $HTMLHeaderFmt[] be populated from within the wiki?  Maybe by
> setting something like $HTMLHeaderFmt[] = "<meta name='keywords'
> content=$ScriptUrl/Site/Keywords/>";
> where the page Site/Keywords contains (:keywords word1,word2, etc:)
> for the site?

Something like that *can* work, but better would probably be
to simply do:

    (:include Site.Keywords:)

If you want it to happen for every page, then you can set
(again, in local/config.php):

    $GroupHeaderFmt = '(:include Site.Keywords:)(:nl:)' . $GroupHeaderFmt;

which means that the contents of Site.Keywords would be
included on every page.  See the FAQ question at the bottom
of http://www.pmwiki.org/wiki/PmWiki/GroupHeaders for the details.

> Then (independent of the answers to my first two questions), to set
> the site's description, I'm guessing you don't just add a second line
> that begins, "$HTMLHeaderFmt[]" - instead, you need to use some array
> syntax?  If so, what would that look like?

$HTMLHeaderFmt[] *is* an array syntax.  :-)  It means to add
a value to the end of the array.  

> I just searched PmWiki.org for "$HTMLHeaderFmt[]" and find it
> introduced on http://www.pmwiki.org/wiki/PmWiki/LayoutVariables, which
> doesn't mention using it for keywords or desciption.  On the other
> hand, keywords and description are introduced here on
> http://www.pmwiki.org/wiki/PmWiki/PageDirectives, where there's no
> mention of $HTMLHeaderFmt.

$HTMLHeaderFmt is a way to add things to the output using PHP
statements (i.e., from within a script), while page directives
are a way to do things from within wiki markup.    So, $HTMLHeaderFmt
is normaly aimed at script writers and wiki administrators, while
the page directives are intended for authors who probably don't
have a way to modify the scripts.  The markup rules for the
page directives convert the markup into the appropriate
$HTMLHeaderFmt entries.

Of course, an administrator can choose whichever approach best
suits his/her needs.  :-)

Pm




More information about the pmwiki-users mailing list