[ View menu ]

Adding keyword and description meta tags to Gallery2

Written on March 27, 2007

The File

Find the template.tpl file for your current theme. I found mine here:
gallery2/themes/matrix/templates/template.tpl

Copy this file to your desktop and open it with your favorite text editor (notepad, perhaps). I prefer Notepad++.

The Code

Add the following lines below the <head> tag near the top of the document:
<meta name="keywords" content="{$theme.item.keywords|markup:strip|default:$theme.item.pathComponent}" />
<meta name="description" content="{$theme.item.description|markup:strip|default:$theme.item.pathComponent}" />

Put it Back

Inside the templates directory, create a new folder called local and upload your modified template.tpl into there. The final path should be something like:
gallery2/themes/matrix/templates/local/template.tpl

Gallery2 looks in the local directory first so that it loads your customized files if there are any. This protects your modified files from being overwritten after a Gallery2 update.

All Done

After this, you’re all done. Load up a gallery page and view source to see the keyword and description tags implemented. If you don’t have any keywords or a description for the album/item, then the path component will be used.

No Comments

Write comment - TrackBack - RSS Comments

You have to be logged in to post a comment.