Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
10.10.2024

How to Add Meta Tags to WordPress

Meta tags are snippets of text that describe a page’s content. They do not appear on the page itself but in the HTML code of the page, providing metadata about the website to search engines. Meta tags such as meta descriptions, title tags, and meta keywords are crucial for SEO (Search Engine Optimization) as they help search engines understand the content of your pages.

Here’s a guide on how to add meta tags to your WordPress website, covering both using plugins and manual methods.

Method 1: Using an SEO Plugin (Recommended)

Using an SEO plugin is the easiest way to add and manage meta tags in WordPress. Popular SEO plugins like Yoast SEO, All in One SEO, and Rank Math provide user-friendly interfaces to add meta tags without editing code.

1.1 Using Yoast SEO

Yoast SEO is one of the most popular SEO plugins for WordPress. Here’s how to add meta tags using Yoast SEO:

Step 1: Install and Activate Yoast SEO

  1. Go to Plugins > Add New in your WordPress dashboard.
  2. Search for Yoast SEO.
  3. Click Install Now, and then click Activate.

Step 2: Add Meta Tags to a Page or Post

  1. Go to Pages or Posts and edit the page or post where you want to add meta tags.
  2. Scroll down to the Yoast SEO box below the content editor.
  3. Click on the SEO tab to add your meta tags:
    • SEO Title: This is your meta title. Yoast will automatically generate one, but you can edit it.
    • Meta Description: Enter a custom meta description for the page. Aim for 150-160 characters to ensure it displays well in search results.
  4. As you type, Yoast provides a preview snippet showing how your meta title and description will appear in Google search results.

Step 3: Save Your Changes

  • Click Update or Publish to save the changes to your page or post.

Tip: Yoast SEO also allows you to set default meta tags for your entire website under SEO > Search Appearance in the Yoast SEO settings.

1.2 Using All in One SEO (AIOSEO)

All in One SEO (AIOSEO) is another powerful plugin for managing meta tags in WordPress.

Step 1: Install and Activate AIOSEO

  1. Go to Plugins > Add New and search for All in One SEO.
  2. Click Install Now, then Activate.

Step 2: Add Meta Tags to a Page or Post

  1. Edit a page or post where you want to add meta tags.
  2. Scroll down to the AIOSEO Settings box.
  3. Under the General tab, you can customize:
    • SEO Title: Enter your desired meta title.
    • Meta Description: Write a meta description for the page.
  4. AIOSEO provides a preview of how your meta tags will appear in search results.

Step 3: Save the Changes

  • Click Update or Publish to save your meta tags.

1.3 Using Rank Math

Rank Math is another user-friendly SEO plugin that allows you to add meta tags directly from the post or page editor.

Step 1: Install and Activate Rank Math

  1. Go to Plugins > Add New and search for Rank Math.
  2. Click Install Now, then Activate.

Step 2: Add Meta Tags to a Page or Post

  1. Edit a page or post where you want to add meta tags.
  2. Scroll down to the Rank Math box.
  3. Under the General tab, customize your SEO Title and Meta Description.
  4. Use the preview to see how your meta tags will appear in search results.

Step 3: Save the Changes

  • Click Update or Publish to save your changes.

Method 2: Manually Adding Meta Tags (Advanced)

If you prefer to manually add meta tags without using a plugin, you can do so by editing the header.php file of your theme or using a custom function in the functions.php file.

2.1 Add Meta Tags in the Header.php File

This method involves editing the header.php file of your WordPress theme. It’s recommended to use a child theme to prevent your changes from being overwritten when your theme updates.

  1. Go to Appearance > Theme File Editor in your WordPress dashboard.
  2. Select the header.php file from the right sidebar.
  3. Add the following code inside the
    <head>
    section:
    <meta name="description" content="Your custom meta description here">
    <meta name="keywords" content="keyword1, keyword2, keyword3">
  4. Replace “Your custom meta description here” with a brief description of your page, and “keyword1, keyword2, keyword3” with relevant keywords.
  5. Click Update File to save your changes.

Note: Be cautious when editing theme files, as errors can break your website.

2.2 Using a Custom Function in Functions.php

If you want to dynamically add meta tags to each page, you can use a custom function in the functions.php file of your theme:

  1. Go to Appearance > Theme File Editor.
  2. Select functions.php from the right sidebar.
  3. Add the following code:
    function add_meta_tags() {
    if (is_single() || is_page()) {
    global $post;
    $description = get_the_excerpt($post->ID);
    echo '<meta name="description" content="' . esc_attr($description) . '">' . "\n";
    }
    }
    add_action('wp_head', 'add_meta_tags');
  4. Click Update File to save the changes.

This code adds a meta description using the excerpt of each page or post. If your posts don’t have excerpts, it will use the first part of your content.

Method 3: Using a Custom Meta Tag Plugin

If you prefer a lightweight plugin specifically for adding custom meta tags without full SEO functionality, you can use plugins like Meta Tag Manager.

  1. Go to Plugins > Add New and search for Meta Tag Manager.
  2. Click Install Now, then Activate.
  3. After activation, go to Settings > Meta Tag Manager.
  4. Click Add Meta Tag and fill in the details:
    • Name: Enter the name of the meta tag (e.g.,
      description
      ).
    • Content: Enter the content of the meta tag.
    • Scope: Choose whether the meta tag applies to all pages or specific ones.
  5. Click Save Meta Tag.

Summary

Adding meta tags to your WordPress website is essential for improving your site’s SEO and making your content more visible in search engine results. Here’s a quick recap of the methods:

  1. Using an SEO Plugin: Plugins like Yoast SEO, All in One SEO, or Rank Math are user-friendly and allow you to add meta tags directly from the page editor.
  2. Manual Method: For those comfortable with code, add meta tags directly to header.php or use a custom function in functions.php.
  3. Using a Meta Tag Plugin: Lightweight plugins like Meta Tag Manager allow for custom meta tag management without extra SEO features.

Choose the method that best fits your needs and technical comfort level, and ensure that your meta tags are optimized for better search engine visibility.

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills