List of available snippet variables in Yoast SEO
One of the most important functions of Yoast SEO is the ability to automatically add SEO title and meta description templates to the homepage, all (custom) post types, all (custom) taxonomies, products, collections, and other pages. We include default templates that are SEO-friendly but you can also modify the default templates. In this article, we’ll provide you with a list of all the available snippet variables in Yoast SEO.
If you want to know more about what snippet variables are and how Yoast SEO uses snippet variables, then you could read this article. Or, to read about how to modify the default snippet template, check out this guide.
Table of contents
- Available variable types in WordPress
- Available snippet variables in Shopify
Available variable types in WordPress
We distinguish four available variable types:
|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|
|Archive title||Replaced with the normal title for an archive generated by WordPress|
|Site title||The site’s name|
|Tagline||The site’s tagline|
|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|
|Tag description||Replaced with the tag description|
|Term description||Replaced with the term description|
|Term title||Replaced with the term name|
|Search phrase||Replaced with the current search phrase|
|Separator||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 how to use these advanced variables, then we advise you not to use them. You can learn more about SEO through our online Yoast SEO academy courses.
|Post type (singular)||Replaced with the content type single label|
|Post type (plural)||Replaced with the content 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’|
|User description||Replaced with the post/page author’s ‘Biographical Info’|
|Page number||Replaced with the current page number with context (i.e. page 2 of 4)|
|Pagetotal||Replaced with the current page total|
|Pagenumber||Replaced with the current page number|
|Focus keyword||Replaced with the posts focus keyphrase|
|Term404||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, then the custom variable would be
%%cf_myfield%%. Or, if the custom field begins with an underscore, for example
_anotherfield, the custom variable should include the underscore like so:
Note: Custom fields that contain arrays (a list of related information) will not work with the custom field variable. Instead, you or your developer should create your own custom template variables.
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%%. Alternatively, if I wanted to output the description of an individual mycategory on the category archive page, I would use
The following variables are some that you can use with WooCommerce. If the specific variable you are looking for is not listed below, then 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
When you are using our Yoast WooCommerce SEO plugin, these additional variables 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)|
Deprecated variables in WordPress
Starting in v7.7 of Yoast, 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. However, they will show up in your source code to maintain backward compatibility, but 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|
|Replaced with the current year|
Default variables in WordPress
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. You can enter these default titles in the SEO-Search Appearance section. This will then assign the defaults as the global template variable for that section.
|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.
Creating custom template variables in WordPress
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.
You might not want Yoast to show these Yoast-created titles. In that case, you can use these filters here.
Available snippet variables in Shopify
The following snippet variables are available in the Yoast SEO for Shopify app:
|Title||Replaced with the title of the blog post or (product/collection) page.*|
|Focus keyphrase||Replaced with the focus keyphrase of the post/page|
|Page number||Replaced with the page number of the current page|
|Separator||The separator defined in your Site defaults|
|Site title||The site’s name|
|Blog title||Replaced with the title of the blog the post belongs to|
|Collection title||Replaced with the title of the collection the (product) page belongs to|
|Product/post tags||Replaced with the current tag/tags|
|Product vendor||Shopify’s “vendor” field; i.e., the brand which manufactures or supplies the product|
|Shopify page title||Shopify’s native product ‘SEO title’|
|Shopify meta description||Shopify’s native product ‘SEO meta description’|
|Product availability||The availability of a product; either ‘In Stock’ or ‘Out Of Stock’|
|Product SKU||The SKU of the product|
|Product barcode||The barcode value of the product|
|Product Price||The (default) price of the product|
|Minimum price of a variable product||The min price of a variable product|
|Maximum price of a variable product||The max price of a variable product|
*Note that on Product variation pages, the
%%title%% variable incorporates information about the current variation. E.g., a product called “The best book ever” with selected variants of “paperback” and “2021 edition” will return a value of “The best book ever – paperback / 2021 edition“.