Content

Custom meta description tag

This example describes how to set a meta description tag per page.

First create a new page as follows.

 page_description=This is the description
 =====
 h2 My page
 Some content

When the site is generated Pagegen will first load all variables found in the content page headers, in this case it will find one called page_description. These variables will be made available to the header executable which uses it to create the HTML title tag.

This example uses a bash script, but any executable that can read environment variables can be used to generate content.

The following header will only print the description meta tag if the page_description variable is defined for the current page. Make the header template executable chmod +x [site dir]/templates/header.

 #!/bin/bash
 echo "<html>"
 echo "<head>"

 if ! [ "$page_description" = "" ]; then
   echo "<meta name="description" content="${page_description}"/>"
 fi

 echo "</head>"
 echo "<body>"
Last changed 2009-10-17 21:09