Thursday, November 26, 2020

How to Add Meta Tags in WordPress

In this tutorial, I'll show you how to add meta tags to your WordPress website. By default, WordPress doesn’t support meta tags, but with a few easy steps you can add support for meta tags in your WordPress website.

Meta tags are important when it comes to making your website SEO-friendly. When search engine crawlers visit your website, they fetch metadata information in the form of meta tags in addition to fetching actual content of that page. In fact, meta tags allow us to inform crawlers about the specifics of the web pages.

There are certain keyword meta tags that don’t contribute to search engine ranking of your website, although some meta tags like meta description can significantly improve search results.

WordPress doesn’t come with built-in support for meta tags, and thus, you need to do a bit of extra work if you want to take advantage of meta tags. Broadly speaking, when it comes to providing meta tags support in WordPress, there are two ways: either you need to edit the WordPress code files or you need to install a third-party plugin. In this article, we’ll discuss both ways.

How to Add Meta Tags to WordPress Without a Plugin

In this section, we’ll discuss how you could enable meta tags support in your WordPress website without any plugins.

To enable meta tags support, we’ll have to add a code snippet in the functions.php file of your active theme. If you're using your own custom theme, you can edit the functions.php file directly. However, if you're using a third-party theme like Twenty Twenty, you should create a child theme before you make any changes.

You can learn how to create a child theme here:

 

In this example, I'll show you the code for a Twenty Twenty child theme. Go ahead and open the wp-content/themes/{YOUR_THEME}/functions.php file and add the following snippet at the end. 

In the above snippet, we’ve added the twentytwenty_add_meta_tags custom function which will be used to add meta tags to the different pages of your website. We’ve then used the wp_head hook to add meta tags in your pages. Of course, if you're using a different theme, replace twentytwenty_add_meta_tags with the name of your own theme. 

As you can see, we’ve implemented meta tags support for the home page, single post page and category pages. Of course, you could go ahead and modify this code as per your needs. You could add support for other types of pages similarly.

In the next section, we’ll see how you could add meta tags by using third party plugins.

How to Add Meta Tags With Third Party Plugins

In this section, we’ll see how you to add meta tags to your website with the help of the Meta Tag Manager plugin. You can install it with from the WordPress admin sidebar with Plugins > Add New, or you can download and install it manually to your wp-content/plugins directory.

Finally, activate the plugin in the Plugins section of the admin sidebar.

Once the plugin is installed, you can access the plugin UI at Settings > Meta Tag Manager.

Meta Tag Manager UI

There are two ways you could use this plugin. You can add custom meta tags for specific pages or you could enable meta tags for specific content types like post, page and media. So it depends on how you would like to configure meta tags in your website.

How to Add the Meta Description Tag for the Front Page

In this section, we’ll see how you could add the meta description tag only on the homepage. Head over to the Settings > Meta Tag Manager > Custom Meta Tags section, click on the + Add Meta Tag button and configure the meta description tag as shown in the following screenshot.

Frontpage Meta Description Tag

Click on the Save Changes button to save your changes.

Meta Tags Listing

Go ahead and check the source code of your front page ( Ctrl + U in Chrome), and you will see the following meta tag added by the Meta Tag Manager plugin!

In this way, you can add as many tags as you want to add to your pages.

How to Enable the Meta Tag Builder for the Post Content Type

The other option is to enable the meta tag builder for specific content types. For example, if you want to enable the meta tag builder for the Post content type, go to the Settings > Meta Tag Manager > General Options section. Select the Posts content type as shown in the following screenshot and hit the Save Changes button to save changes.

General Options

Now, go ahead and create a new post, and you would notice that the meta tag builder is added to it as shown in the following screenshot.

Post Content Type

You would use it in the same way as we discussed in the previous section. In this way, you can enable the meta tag builder for different content types,

Conclusion

Today, we discussed different ways you could use to enable meta tags support in your WordPress website. 

If you want to learn how to make a WordPress site from A to Z, be sure to check out our complete guide.

You can also learn how to use WordPress with our free online course.

 

 

No comments:

Post a Comment