Yoast SEO: Search Appearance template variables
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 to meet your specific needs by following the steps below.
If you want to know how to enter meta descriptions and titles on a page please refer to this guide.
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'.
- Click on 'SEO'.
On the left-hand side, you will see a menu. In that menu, click on 'SEO'.
- Click on 'Search Appearance'.
The ‘SEO’ settings will expand providing you with 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:
||Replaced with the date of the post/page|
||Replaced with the title of the post/page|
||Replaced with the title of the parent page of the current page|
||Replaced with the normal title for an archive generated by WordPress|
||The site's name|
||The site's tagline|
||Replaced with the post/page excerpt (or auto-generated if it does not exist)|
||Replaced with the post/page excerpt (without auto-generation)|
||Replaced with the current tag/tags|
||Replaced with the post categories (comma separated)|
||Replaced with the primary category of the post/page|
||Replaced with the category description|
||Replaced with the tag description|
||Replaced with the term description|
||Replaced with the term name|
||Replaced with the current search phrase|
||The separator defined in your theme's wp_title() tag.|
The following sample of variables requires 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.
|Post type (singular)||
||Replaced with the content type single label|
|Post type (plural)||
||Replaced with the content type plural label|
||Replaced with the post/page modified time|
||Replaced with the post/page ID|
||Replaced with the post/page author's 'nicename'|
||Replaced with the post/page author's 'Biographical Info'|
||Replaced with the current page number with context (i.e. page 2 of 4)|
||Replaced with the current page total|
||Replaced with the current page number|
||Replaced with the posts focus keyphrase|
||Replaced with the slug which caused the 404|
|<custom-field-name> (custom field)||
||Replaced with a posts custom field value. Remove the <>|
|<custom-tax-name> (custom taxonomy)||
||Replaced with a posts custom taxonomies, comma separated. Remove the <>|
|<custom-tax-name> description (custom taxonomy)||
||Replaced with a custom taxonomies description. Remove the <>|
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 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 called
myfield, the custom variable would be
Custom taxonomy names can be found in the browser bar on the backend when viewing or editing an item.
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
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.
||Product category (comma separated)|
||Product tag (comma separated)|
||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.
||Replaced with the short description of the product. (Available as of Yoast WooCommerce SEO 6.2)|
||Replaced with the inventory stock-keeping unit (sku) of the product. (Available as of Yoast WooCommerce SEO 6.2)|
||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)|
||Replaced with price of the product. (Available as of Yoast WooCommerce SEO 6.2)|
We've deprecated these variables as we see no valid use-case for them. If they are used in the snippet editor, they won't appear in the snippet preview, but they will show up in your source code to maintain backward compatibility. We recommend not using them.
||Replaced with the post/page author's userid|
||Replaced with the current time|
||Replaced with the current date|
||Replaced with the current day|
||Replaced with the current month|
If you want to reset the SEO Title template variables back to the defaults use the following below. For meta descriptions the default is blank.
||Posts, Pages, Products, Media, and Custom Post Types|
||Posts, Products, and other Custom Post Type Archive Pages|
||Special Pages: Search Page|
||Special Pages: 404 Pages|
||Author Archive Pages|
||Date Archive Pages|
There are a number of filters documented in the plugin code for developers to programmatically change the template variables. Here are some examples.
Adding your own template variables can be done using the
wpseo_register_extra_replacements filter in your functions.php file. An example of how to use the filter can be viewed here. If you are not sure how to add or use filters, consider working with a Yoast Partner.