Snippet variables in Yoast SEO

Snippet variables have become a staple of Yoast SEO. These variables make it possible to automate certain processes on your site. They also make it easy to change large batches of meta descriptions for instance, since you only have to change the structure of the variable – the site fills in the data automatically. Here, we’ll take a closer look at the snippet variables in Yoast SEO.

Optimize for synonyms and related keywords and prevent broken pages on your site with Yoast SEO Premium! »

Yoast SEO: the #1 WordPress SEO plugin Info

What is a snippet variable?

First things first: a variable is a name or a symbol that stands for a value. For instance, Yoast SEO uses the variable Sitename to get the site name from the site itself. This way, you, as a user, don’t have to type in this information by hand. Now, when the name of the site changes, the variable automatically gets the new name from the site. If you had this hard-coded in your site, you’d have to change everything manually – everywhere. Consider doing this on hundreds of pages and you’ll start to see how powerful variables are.

How does Yoast SEO use variables?

Yoast SEO uses variables to give you the freedom and flexibility you need when working on your SEO. It makes it much easier to find a common ground for your text fields. What’s more, if you ever need to change something, variables let you do this as quickly as possible.

You can find the relevant options in the Search appearance section of the Yoast SEO plugin. There you’ll find loads of options for setting variables to automate your SEO efforts. The full list of variables is listed on the HELP tab of the plugin. Just go to SEO → Search Appearance and click the Need help button in the top left. Then choose the tab ‘template explanation’ and then “snippet variables”. Here you’ll see the list of variables you can use. You can also check our knowledge base article on Snippet variables.snippet variables help

You are free to change any of the settings as you see fit, but remember, the default settings are almost always a great fit for any site. That being said, you can set variables for:

  • Homepage
  • Site title
  • Posts
  • Pages
  • Custom types
  • Categories
  • Tags
  • Archives

How to set variables in Yoast SEO

You can use variables in a multitude of ways. Most site owners only use the most basic ones, while someone more at home in SEO might use the advanced ones. There are even variables for use with WooCommerce, so you can automatically extract product information from your store to use in the metadata. In this post, we’ll keep it simple and give a small example.

If you want to use the variables to automatically generate, for instance, SEO titles and meta descriptions for your posts, you go to Search Appearance –> Content Types and change the template for Posts:

search appearance - snippet variables for posts

You’ll see the field for titles is already pre-populated, but you can change it to whatever you feel what fits your goal.

Snippet editor

If you want, you can also edit the SEO title per single post in the snippet editor of Yoast SEO. There, you’ll find the title according to the variables you’ve chosen above. In addition, you also get the option to override that title with a custom-made variant if you think that’ll attract more clicks in the search engines. The default title variable string is:

seo title - snippet variables

Which, for the post you are now reading, leads to:

snippet editor

These variables combined form the SEO title of the post. In this string, the title takes the title of the post, adds a page number if any (f.i. page 3 of 4), the separator symbol you picked and the site name of the site it’s posted on.

With the plus in the upper right corner you can add lots of other variables in there, but remember, you’re working with limited space for the snippets. If you’d add a category, for instance, the title would become too long and Google would cut it off. Try to find a middle ground between readability, findability and branding. Yes, your branding is important, so don’t omit sitename.

Using variables for SEO

Yoast SEO supports a wide range of variables and they can be used for almost any situation. You should, however, always ask yourself if the change you want to make improves your metadata. If not, why not let the default settings do their work? Experienced SEOs will enjoy using the advanced variables and online store owners can make use of the extra WooCommerce variables. For the rest of you? Don’t overdo it.

Read more: Why every website needs Yoast SEO »

5 Responses to Snippet variables in Yoast SEO

  1. Ajay Sharma
    Ajay Sharma  • 12 months ago

    Thanks Edwin for sharing this blog. I own a Tech blog named TechWebSpace and will be using these title & meta variables. thanks again for the guide.

  2. cameronjonesweb
    cameronjonesweb  • 12 months ago

    I’ve run in to a situation where I need to build a custom variable, are there any tutorials on this anywhere?

  3. Nick Leffler
    Nick Leffler  • 12 months ago

    The variables from Yoast have been extremely helpful in making it easy to change large portions of my site with little issue. I sometimes combine plain text and variables to get a good format for my titles that make sense and works better than just the straight variable. I use those mostly for things like categories and tags.

  4. David Southall
    David Southall  • 12 months ago

    Hi new Yoast Pro owner so I’m a noob, so my question is:

    Can I create webpages say using php as an automated process and set say tags that should I later open in the WordPress backend that will populate the Yoast fields such as “Focus keyword”

    Regards Dave

  5. juniorwaar
    juniorwaar  • 12 months ago

    Ótimas recomendações ! Obrigado


Check out our must read articles about Analytics

Tools to improve your online marketing campaign

Take your online marketing to the next level with these easy-to-use and insightful online marketing tools to help you optimize your site!

Read article »

Tracking your SEO with Google Analytics: a how-to

How do you start tracking your SEO? In this how-to guide, we'll explain how to track your SEO with Google Analytics!

Read article »

Twitter Analytics: stats for your tweets

Twitter Analytics can help you set up and maintain the right Twitter strategy. We'll explain what can be learned from Twitter Analytics.

Read article »