Yoast SEO: Titles & Metas template variables

Last update: 30 March, 2018

One of the most important functions of both Yoast SEO (free or premium) is the ability to automatically add title and description templates to the homepage, all (custom) post types, all (custom) taxonomies and other pages. We include default templates that are SEO friendly but you can modify the default templates using to meet your specific needs by following the steps below.

Template Variables

Get access to our kick-ass support team with Yoast SEO Premium

Modify default templates

Yoast SEO automatically adds default templates to all content across your site. You can change your title & meta templates by going to the admin of your WordPress installation and clicking SEO → Search Appearance.

  • Log in to your WordPress website. When you're logged in, you will be in your 'Dashboard'. On the left-hand side, you will see a menu. In that menu, click on 'SEO'.
  • The ‘SEO’ settings will expand providing you additional options. Click on 'Search Appearance'.
  • Under each tab, you can use these variables to create templates for various pages within your site.

You can use the variables from the partial list below to create your own templates for the titles and meta-descriptions. The full list of variables is listed on the HELP tab of the plugin. Just go to SEO → Search Appearance and click the help tab in the top right.

You'll find it here:

NOTE: Below you will find only a sampling of the available variables. Please check the Help Center in your Search Appearance section for the complete list available to your site.

Basic Variables

%%date%% Replaced with the date of the post/page
%%title%% Replaced with the title of the post/page
%%parent_title%% Replaced with the title of the parent page of the current page
%%sitename%% The site's name
%%sitedesc%% The site's tagline / description
%%excerpt%% Replaced with the post/page excerpt (or auto-generated if it does not exist)
%%excerpt_only%% Replaced with the post/page excerpt (without auto-generation)
%%tag%% Replaced with the current tag/tags
%%category%% Replaced with the post categories (comma separated)
%%primary_category%% Replaced with the primary category of the post/page
%%category_description%% Replaced with the category description. This works on category pages.
%%tag_description%% Replaced with the tag description. This works on tag pages.
%%term_description%% Replaced with the term description. This will only work on custom taxonomy pages.
%%term_title%% Replaced with the term name
%%searchphrase%% Replaced with the current search phrase
%%sep%% The separator defined in your theme's wp_title() tag.
%%archive_title%% Replaced with the normal title for an archive generated by WordPress

The following sample of variables require a better understanding of SEO. If you're unsure about how to correctly use this, don't. Or you can purchase an online training course at Yoast.

Advanced Variables

%%pt_single%% Replaced with the post type single label
%%pt_plural%% Replaced with the post type plural label
%%modified%% Replaced with the post/page modified time
%%id%% Replaced with the post/page ID
%%name%% Replaced with the post/page author's 'nicename'
%%userid%% Replaced with the post/page author's userid
%%currenttime%% Replaced with the current time
%%currentdate%% Replaced with the current date
%%currentday%% Replaced with the current day
%%currentmonth%% Replaced with the current month
%%currentyear%% Replaced with the current year
%%page%% Replaced with the current page number (i.e. page 2 of 4)
%%pagetotal%% Replaced with the current page total
%%pagenumber%% Replaced with the current page number
%%caption%% Attachment caption
%%focuskw%% Replaced with the posts focus keyword
%%term404%% Replaced with the slug which caused the 404
%%cf_<custom-field-name>%% Replaced with a posts custom field value. Be sure to remove the <> as they are not needed.
%%ct_<custom-tax-name>%% Replaced with a posts custom taxonomies, comma separated. Be sure to remove the <> as they are not needed.
%%ct_desc_<custom-tax-name>%% Replaced with a custom taxonomies description. Be sure to remove the <> as they are not needed.

Custom Variables

The last three advanced variables can be used to output data from non-standard WordPress elements, such as WooCommerce products. But how do you find the name of the correct field or taxonomy to use these variables?

Custom Fields

Custom field names can be found using the steps here. Once you have the custom field name, you will replace <custom-field-name>. If my custom field was calledmyfield, the custom variable would be %%cf_myfield%%.

Custom Taxonomies

Custom taxonomy names can be found in the browser bar on the backend when viewing or editing an item.

Example: edit-tags.php?taxonomy=mycategory&post_type=myposttype

In the example above, we are editing a custom taxonomy called mycategory under a custom post type called myposttype. If I wanted to output a list of categories assigned to a myposttype page, I would use %%ct_mycategory%%. If I wanted to output the description of an individual mycategory on the category archive page, I would use %%ct_desc_mycategory%% .

WooCommerce Variables

The following are some variables you may use with WooCommerce. If the specific variable you are looking for is not listed below, please use the custom  variable information above to find the variable you need.

%%ct_product_cat%% Product category (comma separated)
%%ct_product_tag%% Product tag (comma separated)
%%ct_pa_<product-attribute-slug>%% Product attribute (comma separated). Be sure to remove the <> as they are not needed.

Yoast WooCommerce SEO Variables

If you have our Yoast WooCommerce SEO plugin these additional filters are available.

%%wc_shortdesc%% Replaced with the short description of the product. (Available as of Yoast WooCommerce SEO 6.2)
%%wc_sku%% Replaced with the inventory stock-keeping unit (sku) of the product. (Available as of Yoast WooCommerce SEO 6.2)
%%wc_brand%% Replaced with the brand name. This variable only works with 'WooCommerce Brands' and 'Perfect WooCommerce Brands' plugins. (Available as of Yoast WooCommerce SEO 6.2)
%%wc_price%% Replaced with price of the product. (Available as of Yoast WooCommerce SEO 6.2)

Available Developer Filters

This guide below is written for advanced users and developers. Looking for a web developer to customize our plugin? We highly recommend checking out Code Poet as they have a great list of available freelance WordPress developers.

There are a number of filters documented in the plugin code for developers to programatically change the template variables. Here are some examples.

Was this article helpful? ·