Forums / Developer / Meta Description tag

Meta Description tag

Author Message

Dries Samyn

Wednesday 23 June 2004 3:05:00 am

I've got a problem with teh meta decription tag. When I try to change it by changing the

MetaDataArray[description]=Description Meta data

setting, it doesn't change anything. It looks like it's outputting the "path" (similartly to what it does by default with the page title).
I have no idea why that happens. Even trying to remove it in the site.ini file doesn't change anything.

Does anybody know why this could be?

Also, related, does anybody know of a why to customise this? Ideally I would like a textfield in the CMS so the description can change for each page, but unfortunatly, I don't think there is a way for me to get access to CMS content from the pagelayout template.

Any ideas?

Cheers,

Dries.

Ekkehard Dörre

Wednesday 23 June 2004 3:19:52 am

Hi Dries,
you can change page_head.tpl
make a new class with title and 1 textfield (not xmltext) or take some text (not xml) from eg. the product class:


{*?template charset=latin1?*}
{default enable_help=true() enable_link=true()}

{let name=Path
     path=$module_result.path
     reverse_path=array()}
  {section show=is_set($module_result.title_path)}
    {set path=$module_result.title_path}
  {/section}
  {section loop=$:path}
    {set reverse_path=$:reverse_path|array_prepend($:item)}
  {/section}

{set-block scope=root variable=site_title}
{section loop=$Path:reverse_path}{$:item.text|wash}{delimiter} / {/delimiter}{/section} - {$site.title|wash}
{/set-block}

{/let}
 {let titel_meta_list=fetch( content, list, hash( parent_node_id, $DesignKeys:used.node,
                                                          limit, 1,
                                                         sort_by, array( array( priority , false()) ),
                                                          class_filter_type, include,
                                                          class_filter_array, array( your_class eg. product ) ) )}
    <title>{$site_title}{section name=Titel_Meta loop=$titel_meta_list} - {$Titel_Meta:item.name|wash}{/section}</title>
      {/let}





    {section show=and(is_set($#Header:extra_data),is_array($#Header:extra_data))}
      {section name=ExtraData loop=$#Header:extra_data}
      {$:item}
      {/section}
    {/section}

    {* check if we need a http-equiv refresh *}
    {section show=$site.redirect}
    <meta http-equiv="Refresh" content="{$site.redirect.timer}; URL={$site.redirect.location}" />

    {/section}

    {section name=HTTP loop=$site.http_equiv}
    <meta http-equiv="{$HTTP:key|wash}" content="{$HTTP:item|wash}" />

    {/section}

    {section name=meta loop=$site.meta}

    {section show=eq("description",$meta:key)}

     <meta name="{$meta:key|wash}" content="{$meta:item|wash}{section name=Titel_Meta loop=fetch( content, list, hash( parent_node_id, $DesignKeys:used.node,
                                                          limit, 1,
                                                         sort_by, array( array( priority , false()) ),
                                                          class_filter_type, include,
                                                          class_filter_array, array( your_class eg. product ) ) )}, {attribute_view_gui attribute=$:item.object.data_map.description}{/section}" />
  {section-else}
  {section show=eq("keywords",$meta:key)}

     <meta name="{$meta:key|wash}" content="{$meta:item|wash}{section name=Titel_Meta loop=fetch( content, list, hash( parent_node_id, $DesignKeys:used.node,
                                                          limit, 1,
                                                         sort_by, array( array( priority , false()) ),
                                                          class_filter_type, include,
                                                          class_filter_array, array( your_class eg. product ) ) )}, {$:item.name|wash}{/section}" />
  {section-else}
    <meta name="{$meta:key|wash}" content="{$meta:item|wash}" />
    {/section}
    {/section}
    {/section}

    <meta name="MSSmartTagsPreventParsing" content="TRUE" />
    <meta name="generator" content="eZ publish" />

{section show=$enable_link}
    {include uri="design:link.tpl" enable_help=$enable_help enable_link=$enable_link}
{/section}

{/default}

it isn't elegant because of 3 queries, but it works.
It is the extension of http://ez.no/community/forum/setup_design/search_engine_optimisation_more_efficient_use_of_the_title_tag

Greetings ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Dries Samyn

Wednesday 23 June 2004 4:50:47 am

thanks for the response. I created a meta data class, and this works great.
Only thing that isn't so good is that there is a linebreak in the HTML before it outputs the text. I think most spiders and bots require the meta data to be in one line.

I suppose I have to wait for the {strip} operator ;)

Ekkehard Dörre

Wednesday 23 June 2004 8:02:18 am

Hi,

I've no linebreak in tag, only between:

 <meta name="description" content="blabla , blabla " />

      
      
     <meta name="keywords" content="blabla blabla " />

You can strip the lines and spaces between the tags, but then the template is hard to read for humans.
Perhaps there is linebreack in your input?

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Dries Samyn

Wednesday 23 June 2004 8:22:01 am

Strange that. I have

<meta name="description" content="
blah lala" />

The code I use is

<meta name="{$meta:key|wash}" content="{section name=Titel_Meta loop=fetch( content, list, hash( parent_node_id, $DesignKeys:used.node,
	                                                         limit, 1,
	                                                         sort_by, array( array( priority , false()) ),
	                                                         class_filter_type, include,
	                                                         class_filter_array, array( 'csa_meta_data' ) ) )}{attribute_view_gui attribute=$:item.object.data_map.meta_description}{/section}" />

With meta_description being a standard text field with no line breaks.

Thanks for helping me out on this one btw!

Ekkehard Dörre

Wednesday 23 June 2004 2:55:57 pm

Funny,
Turn in yoursiteaccess/site.ini.append.php template debug on:

[DebugSettings]
DebugOutput=enabled

[TemplateSettings]
Debug=enabled

And look where {attribute_view_gui attribute=$:item.object.data_map.description} is built. I think, there is the linebreak, but I don't know.

Happy template digging ;-)

ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Rinze Cats

Wednesday 30 June 2004 3:13:52 am

I use the following code to display the metadata from the metadataarray, unless the current page has a specific description or keywords (which are simply attributes of my article class.

I am currently experiencing problems only with the description metadata field. I think this is a bug

{section name=meta loop=$site.meta}
{switch match=$meta:key|wash}
{case match=description}
{section show=is_set($current_node.data_map.description)}
{section show=ne($current_node.data_map.description.content, "")}
<meta name="{$meta:key|wash}" content="{$current_node.data_map.description.content}"/>

{section-else}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/section}
{section-else}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/section}
{/case}
{case match=keywords}
{section show=is_set($current_node.data_map.keywords)}
{section show=ne($current_node.data_map.keywords.content, "")}
<meta name="{$meta:key|wash}" content="{$current_node.data_map.keywords.content}"/>

{section-else}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/section}
{section-else}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/section}
{/case}
{case}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/case}
{/switch}
{/section}

Pål Messenlien

Thursday 24 November 2005 3:30:01 pm

I know this is a old post. But it helped me getting what i wanted. I used the code Rinze posted, thanks alot! The reason im replying is that i found the reason for the description bug. When your checking code from the start page for example. You got a meta tagged that looked like this

meta name="description" content="Object(ezxmltext)"

The reason for this is that your standing in a folder, and default the folder class got a xml field called description. The workaround i found is to just use another name for the description field. I also had to use $node instead of $current_node, might be because im using a 3.6.* site? Anyway the working code for my page_head.tpl looks like this.

{* DO NOT EDIT THIS FILE! Use an override template instead. *}
{*?template charset=latin1?*}
{default enable_help=true() enable_link=true()}

{let name=Path
     path=$module_result.path
     reverse_path=array()}
  {section show=is_set($module_result.title_path)}
    {set path=$module_result.title_path}
  {/section}
  {section loop=$:path}
    {set reverse_path=$:reverse_path|array_prepend($:item)}
  {/section}

{set-block scope=root variable=site_title}
{section loop=$Path:reverse_path}{$:item.text|wash}{delimiter} / {/delimiter}{/section} - {$site.title|wash}
{/set-block}

{/let}

    <title>{$site_title}</title>

    {section show=and(is_set($#Header:extra_data),is_array($#Header:extra_data))}
      {section name=ExtraData loop=$#Header:extra_data}
      {$:item}
      {/section}
    {/section}

    {* check if we need a http-equiv refresh *}
    {section show=$site.redirect}
    <meta http-equiv="Refresh" content="{$site.redirect.timer}; URL={$site.redirect.location}" />

    {/section}

    {section name=HTTP loop=$site.http_equiv}
    <meta http-equiv="{$HTTP:key|wash}" content="{$HTTP:item|wash}" />

    {/section}

    {section name=meta loop=$site.meta}
{switch match=$meta:key|wash}

{case match=description}
{section show=is_set($node.data_map.ndescription)}
{section show=ne($node.data_map.ndescription.content, "")}
<meta name="{$meta:key|wash}" content="{$node.data_map.ndescription.content}"/>

{section-else}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/section}
{section-else}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/section}
{/case}
{case match=keywords}
{section show=is_set($node.data_map.keywords)}
{section show=ne($node.data_map.keywords.content, "")}
<meta name="{$meta:key|wash}" content="{$node.data_map.keywords.content}"/>

{section-else}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/section}
{section-else}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/section}
{/case}

{case}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}"/>

{/case}
{/switch}
{/section}

    <meta name="MSSmartTagsPreventParsing" content="TRUE" />
    <meta name="generator" content="eZ publish" />

{section show=$enable_link}
    {include uri="design:link.tpl" enable_help=$enable_help enable_link=$enable_link}
{/section}

{/default}

Hope its usefull for someone.

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

manu let

Wednesday 16 January 2008 2:21:11 am

THE FOLLOWING IS WORKING FINE:

Insert custom metatags in the folder's and article class.

Created the custom attributes for meta_description and meta_keys as text field on the folder class...make sure they are not set up as information collector or it will NOT WORK!
I have then the following Page_Head.tpl

<meta name="description" content="" />
<meta name="keywords" content="" />

What i am doing wrong? Please help, i have been on this for 10 days now and seriously struggling!!!

{* DO NOT EDIT THIS FILE! Use an override template instead. *}
{*?template charset=latin1?*}
{default enable_help=true() enable_link=true()}

.. snip


{let node_metas=fetch(content, node, hash(node_id, $module_result.node_id))}

 <meta name="description" content="{$node_metas.object.data_map.meta_description.content}" />
 <meta name="keywords" content="{$node_metas.object.data_map.meta_keys.content}" />

 {/section}
{/let}

.. snip

{/default}

And what is created is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head>        
                      

 <meta name="description" content="my description" />
 <meta name="keywords" content="my keywords" />

    <title>Our Team / Home - Website Interface</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-language" content="en-GB" />
    <meta name="MSSmartTagsPreventParsing" content="TRUE" />
    <meta name="generator" content="NeatNet" />

Bonne chance!
Regards,
EL