User Tools

Site Tools


zencartmods:meta_tags.html

Adding META Tags to Define Pages

An easy feature to miss in the zen cart code is the ability to customize your meta tags for individual pages.

For categories and products, the meta tag editors are nice and can be accessed by clicking button at the far right of the categories/products section.

For define pages (the static pages that aren't products - like "contact us"), it gets a little trickier.

In the /includes/modules/meta_tags.php file, you'll find code that looks like this

// if per-page metatags overrides have been defined, use those, otherwise use usual defaults:                                                                                                                                                                                 
if ($current_page_base != 'index') {
  if (defined('META_TAG_TITLE_' . strtoupper($current_page_base))) define('META_TAG_TITLE', constant('META_TAG_TITLE_' . strtoupper($current_page_base)));
  if (defined('META_TAG_DESCRIPTION_' . strtoupper($current_page_base))) define('META_TAG_DESCRIPTION', constant('META_TAG_DESCRIPTION_' . strtoupper($current_page_base)));
  if (defined('META_TAG_KEYWORDS_' . strtoupper($current_page_base))) define('META_TAG_KEYWORDS', constant('META_TAG_KEYWORDS_' . strtoupper($current_page_base)));
}

So these 3 meta tag fields can be customized, just not through the Admin.

So to create a custom title, description, and keywords for a page like "Contact us",

Add these lines into /includes/languages/english/contact_us.php

define('META_TAG_TITLE_CONTACT_US', 'This is the new custom title for the contact us page.');
define('META_TAG_DESCRIPTION_CONTACT_US', 'This is the new custom description for the contact us page.');
define('META_TAG_KEYWORDS_CONTACT_US', 'Contact, Us');

As always when dealing with meta tags, remember not to go overboard with them! Google won't even look at your keywords, and descriptions are only used to generate the blurb that is given to a user - it will never affect your page ranking. Simple and human-readable is always the best.

/home/ladyada/public_html/wiki/data/pages/zencartmods/meta_tags.html.txt · Last modified: 2016/01/28 18:05 (external edit)