Slim SEO v4: Configuring Meta Tags With Dynamic Variables

In the new Slim SEO 4.0 version, there will be a very new, huge, and special feature that allows users to configure meta tags through dynamic variables. It will help users to set up meta tags more flexibly for all post types and taxonomies. It's really flexible, easy, and extremely powerful.

Introducing dynamic variables in Slim SEO

Why dynamic variables?

By default, WordPress sets the meta title to "post title - site title". But if you have an "event" post type and want to set the meta title to show the address and the date for all events. So when people search for events, they'll immediately see the details. Or you have a "book" post type and you want to show the author name of the book in the meta title.

It's not that it can't be done before, but it won't be able to do for a whole series of events because you have to write by hand for each event or book. It will be very time-consuming!

There's another popular example is review articles. When you write a review, let's say, Slim SEO vs. SEOPress, it needs to be updated every year. So every time you update it, you should change the year on the title to something like "2024 review". You'll need a way to update the year in the title automatically.

All the above can be done through a new feature of Slim SEO - dynamic variables.

What are dynamic variables?

Essentially, a dynamic variable is a tag whose value can be changed according to the content or data of the article, website, or in real time. For example:

  • the {{ post.title }} variable will be automatically replaced
    by the title of the current article
  • {{ post.custom_field.date }} will be automatically replaced by the value of the custom field date,
  • {{ current.year }} will be automatically replaced by the current year

In other words, dynamic variables will allow you to use dynamic data in meta tags like title, meta description, Open Graph image, canonical URL, etc. Their value will be updated based on the data of the current post, the website, the author, and so it will help you eliminate the effort to enter by hand the custom values for the title or meta description.

How to use dynamic variables in Slim SEO?

Accessing the Meta Tags tab in Slim SEO settings page to configure meta tags for homepage, post types, and taxonomies.

Go to Settings > Slim SEO, you'll see a new tab Meta Tags, replacing the two old tabs in previous versions, Homepage and Post Types. This tab allows you to configure meta tags for all types of content, including homepage, post types, taxonomies, and other pages, such as author archives.

For each type of content, you can configure meta title, meta description, Facebook and Twitter images. To load the dynamic variables, you just need to click the "3 dots" icon and select a dynamic variable:

Showing popup to pick dynamic variables for meta tags

When you select it, it will be inserted into the input box. You can select/insert multiple variables as you want. You can also type the variable into the input box, or type text between them.

Using dynamic variables for single posts and terms

When you edit a single post, or single term (category, tag, or any taxonomy), the plugin also provides you with the same dynamic variables. But there is a big difference: you can preview the value of the meta tags as soon as you write it. This is a very important point for you to see how they are rendered as well as their length (and you'll see an indicator for whether they're too long or too short).

Use dynamic variables for single posts with preview

There is a small note about the preview. For post types or taxonomies in the settings page, the indicator for the number of characters and also the preview may not work. The reason is that the plugin won't be able to know which specific post or term you're configuring for. So, generating a preview won't be possible.

What dynamic variables are available?

Slim SEO supports some of the dynamic variables that have been carefully selected. These are variables for:

  • Post
  • Post type which is used for the post type archive page
  • Taxonomy
  • Author/User
  • Site
  • Some miscellaneous variables for the current year, page number, and separator character

Among these variables, there are some special variables like {{ post.auto_description }}, which is generated automatically from the post's excerpt. And if there is no excerpt, it will be generated automatically from the post's content. And for the term, the variable {{ term.auto_description }} will be generated automatically from the term description.

And there is a very important variable: the {{ post.custom_field.xxx }}, which allows you to choose a custom field for a meta tag. Currently, Slim SEO supports basic custom fields and will work well for most custom fields, including ACF and Meta Box. In the future, we will try to improve so that the custom field support can work for complex fields in Meta Box and ACF.

What about performance?

We have implemented this dynamic variable feature in our premium plugin - Slim SEO Schema, and it uses variables to get data and fields for the properties of the schema. This version in Slim SEO is a similar version in Slim SEO Schema. However, we have made a lot of changes and improvements to ensure great performance for Slim SEO.

As you might notice, the variable syntax is very similar to Twig. However, we didn't include all the Twig library in the plugin. We just wrote a tiny version, that can parse the variables. It's probably just 1% of Twig and we are quite satisfied with it.

And all the parts we do on the settings page are built with React, which is bundled with WordPress. We use that to stay as close as possible to WordPress, in terms of both functionality and UI/UX.

Feedback

We hope that this improvement can bring you a better experience using Slim SEO and we're open to any suggestions or feedback to make the next improvement better. If you like or dislike it, please let us know in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *