META DESCRIPTION & KEYWORDS

morvak

Joined: 2004-11-22
Posts: 30
Posted: Sat, 2005-04-23 22:10

Some search engines do not use META DESCRIPTION and KEYWORDS anymore, but some still do I think, and who knows, maybe they still help your pages to be found on the internet.

So with friendly url mod in use i thought it might be a good idea to see if i could pull the album and image's descriptions and keywords and place them into the header of the page being viewed so that people's sites, images and pages could be found more easily when searching on the internet and what-not.

Go to global.tpl in the /gallery2/templates directory and place the following code between the <head> </head> tags as follows:

<head>
{* This should help out users whose browsers are confused about the character set *}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

{* Content that G2 wants to display inside the <head> element *}
{g->head}
<meta name="description" content="{$layout.item.description|markup}">
</head>

I'm still looking for the $code which represents the keywords for the image/album so we can accomplish the following:

<meta name="keywords" content="{$gallerykeywordsforimage}">

anyone know what the $code for the keywords would be?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-04-23 22:59

good call. could / should be done as module.

 
morvak

Joined: 2004-11-22
Posts: 30
Posted: Sat, 2005-04-23 23:02

yeah, good idea! anyone? ;-) i have no idea how to do a module!

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2005-04-23 23:06

here's a start:
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=23200

and did you try $layout.item.keywords ?

 
morvak

Joined: 2004-11-22
Posts: 30
Posted: Sat, 2005-04-23 23:22
mindless wrote:
here's a start:
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=23200

and did you try $layout.item.keywords ?

like a charm, thanks mindless! so there we have it:

<meta name="description" content="{$layout.item.description|markup}">
<meta name="keywords" content="{$layout.item.keywords}">

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2005-04-24 00:26

FYI, it's more appropriate to put this in a local layouts/matrix/templates/head.tpl because $layout.item won't exist on every G2 view, but will exist whenever head.tpl is used.

 
morvak

Joined: 2004-11-22
Posts: 30
Posted: Sun, 2005-04-24 01:33

ok.. well, my current matrix head.tpl only contains a <title> tag... should i just put the above code before this tag?

maybe my question should be: is the matrix/templates/head.tpl called into the head section so that whatever i put into head.tpl will be placed in the <head> section ?

err heheh i think i'm a little confused!

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2005-04-24 01:58

yes, head.tpl is included in the <head> section.. hence, the name..

 
sconnelly
sconnelly's picture

Joined: 2005-05-07
Posts: 34
Posted: Sun, 2005-08-28 20:53
morvak wrote:
mindless wrote:
here's a start:
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=23200

and did you try $layout.item.keywords ?

like a charm, thanks mindless! so there we have it:

<meta name="description" content="{$layout.item.description|markup}">
<meta name="keywords" content="{$layout.item.keywords}">

This didn't work for me when using G2, since my description had some BBCode markup. That made the description show up in the body of the browser. After some digging, here's the code I used to make this work with G2-RC2

<meta name="description" content="{$layout.item.description|markup:strip}">
<meta name="keywords" content="{$layout.item.keywords}">

This strips out all the HTML markup from the descriptions.

 
jppaz

Joined: 2005-08-18
Posts: 47
Posted: Tue, 2005-09-06 18:11

This didn't work for me when using G2 :(

<meta name="KEYWORDS" content="{$layout.item.keywords}" />
<meta name="DESCRIPTION" content="{$layout.item.description|markup:strip}" />

But, this is ok :D

<meta name="KEYWORDS" content="{$theme.item.keywords}" />
<meta name="DESCRIPTION" content="{$theme.item.description|markup:strip}" />

 
piotrpix

Joined: 2006-08-20
Posts: 17
Posted: Tue, 2006-08-29 20:39

Hi im using the seriux theme and i cant get my meta to show up in view source code:

I have the following code in (theme.tpl):

{*
 * $Revision: 1.5 $
 * If you want to customize this file, do not edit it directly since future upgrades
 * may overwrite it.  Instead, copy it into a new directory called "local" and edit that
 * version.  Gallery will look for that file first and use it if it exists.
 *}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
{if empty($head.title)}
{if $theme.pageType == 'photo'}
<title>{$theme.parent.title|markup:strip} - {$theme.item.title|default:$theme.item.pathComponent|markup:strip}</title>
{else}
<title>{$theme.item.title|markup|default:$theme.item.pathComponent|markup:strip}</title>
{/if}
{/if}

<meta name="KEYWORDS" content="{$theme.item.keywords}" />
<meta name="DESCRIPTION" content="{$theme.item.description|markup:strip}" />

    {* Include this theme's style sheet *}
    <link rel="stylesheet" type="text/css" href="{g->theme url="theme.css"}"/>



    <style type="text/css">

	{if !empty($theme.params.thumbnailSize)}
	  {assign var="thumbCellSize" value=$theme.params.thumbnailSize+30}
	  .gallery-thumb {ldelim} width: {$thumbCellSize}px; height: {$thumbCellSize}px; {rdelim}
	  .gallery-album {ldelim} height: {$thumbCellSize+30}px; {rdelim}
	{/if}
    </style>


  </head>

Can someone tell me whats the problem

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-08-29 20:59

do you see content="" or no <meta> tag at all? it looks fine, so maybe you put this in the wrong theme.tpl file. a URL would be helpful.

 
piotrpix

Joined: 2006-08-20
Posts: 17
Posted: Wed, 2006-08-30 09:43

I see no meta at all. Like it wasnt in the code. Strange... The site is localhost.