How to Add Meta Tags in WordPress

When search engines index your website, you will want them to understand what it’s all about. That way, they can do a better job of showing your pages to interested browsers.

Fortunately, you can affect what information is shown in search results by adding meta tags to your website. This enables you to show off your content to browsers, and encourages them to click through. Plus, it doesn’t have to be a complicated process.

In this article, we’ll cover what meta tags are and why they are important. We’ll then look at how to add them to your website, both with and without a plugin. Let’s get to work!

What Are Meta Tags?

A meta tag is a snippet of HTML code that describes the content of a website or a specific web page. These bits of data tell search engines what the page is about, and provide the content that will be displayed in search engine results.   

Why Are Meta Tags Important?

Meta tags are not as important as they used to be, because search engines no longer use them to determine rankings. However, this does not mean you should ignore them. After all, meta tags still provide the description shown in search engine results, which can greatly increase your Click-Through Rates (CTRs).

Method 1: Using the Yoast SEO Plugin

The Yoast SEO plugin offers built-in support for description and keyword meta tags:

This has made it one of the most common methods for adding meta tags to WordPress. Let’s take a look at how that process works.

Step 1: Install the Yoast SEO Plugin

To start adding meta tags to your content, you’ll first need to download the Yoast SEO plugin. You can find it by searching for “Yoast SEO” in your dashboard under the Plugins page.

The plugin will need to be activated after it has been installed. There’s both a free and a premium version, but the free version will be sufficient for adding meta tags.

Step 2: Add Meta Data to Your Posts and Pages

Once the plugin has been activated, navigate to Pages > All or Posts > All, depending on the type of content you want to add meta tags to. Click on Edit, and then scroll to the bottom of the screen where the Yoast SEO section is located:

Enter your primary keyword into the Focus Keyphrase section. Then, click on the Edit Snippet button to enter your meta description. This will be displayed in search engines, and should be a short paragraph describing the page’s content and encouraging browsers to click through.

Step 3: Save or Publish the Post or Page

Before moving on, it’s a good idea to read over your meta tags and description. Do they summarize the content of the page accurately, and are they unique and compelling?

Once you are happy with your meta tags, save the post or page, or publish it if you haven’t already. That’s all you have to do!

Method 2: Without a Plugin

While Yoast SEO is the most common and simplest way to add meta tags to WordPress, it can also be done without a plugin. Manually adding the necessary HTML tags to your header.php file is simple, but the tags will not be retained if you change your website’s theme. These meta tags will also apply to the entire website, and will not be unique to each post or page.

Step 1: Open the header.php File

To add meta tags in WordPress without a plugin, you’ll need to open the header.php file. This can be opened using File Manager or a Secure File Transfer Protocol (SFTP) client:

Once the file is open, you’ll need to look for the <head> tag. Your meta data should be placed within those tags.

Step 2: Copy and Customize the Meta Tags

Next, copy the generic keyword meta tag below and paste it under the opening <head> tag:

<meta name="keywords" content="keywords related to the content of the website" />

Then copy the generic description meta tag below, and paste it under the previous line:

<meta name="description" content="meta description for the content of the website" />

After that, you can replace the placeholders and fill in your own keywords and meta description. Both should be optimized for the content of your website as a whole.

Step 3 (Optional): Use a Conditional Tag Query

If you want a different description for single-post views and multiple-post views, you can do that too. First, navigate to Admin > Options > General, and enter your meta description into the Tagline section.

Then, the conditional tag query below can be added to your header.php file: 

<meta name="description" content="<?php if ( is_single() ) {
        single_post_title('', true); 
    } else {
        bloginfo('name'); echo " - "; bloginfo('description');
    }
    ?>" />

The conditional tag query will show the post’s title in a single-post view. Alternately, the blog name and description will be shown in multiple-post views. 

Summary: Key Details

Learning how to add meta tags in WordPress is fairly simple. You can use the Yoast SEO plugin to dynamically insert meta tags for each post and page on your website. You can also manually add meta tags to the header.php file. For dynamic meta description tags, you can use a conditional tag query.

Keep Learning with WP Engine

Learning how to add and use the right meta tags can make a big difference to your website’s SEO. Optimized description tags can make your content more appealing in search engines, and should be retained when migrating posts and pages.

As a developer, you need to know how to do things like use meta tags and copy a development environment. WP Engine offers the best resources to help you learn everything you need, and build a smooth digital experience for your customers!

Get started.

Build faster, protect your brand, and grow your business with a WordPress platform built to power remarkable online experiences.