Meta tags are a crucial part of your website’s SEO strategy, providing search engines and browsers with important information about your content. In WordPress, adding meta tags can be done in various ways, from manually editing theme files to using plugins. This guide will walk you through the most common methods.
Understanding Meta Tags
Meta tags are snippets of text that describe a page’s content; they don’t appear on the page itself but only in the page’s code. Common meta tags include the meta description, keywords, and viewport settings. These tags help search engines understand the content and relevance of your website, which can impact your rankings.
Method 1: Adding Meta Tags Manually
Editing the header.php
File
One of the easiest and straightforward ways to add meta tags is directly editing your header.php
file. This is the place where meta tags are placed and also controls what appears in the <head>
section of your HTML. You’ll need some technical know-how to pull this off. Therefore we have enumerated all the necessary steps that you might require.
Access the Theme Editor: First of all, you’ll need to access the theme editor of your WordPress. Navigate to Appearance and then to the Theme File Editor. There you’ll find all the necessary files of your website.
Locate
header.php
: Once you have accessed the theme editor, now it’s time to locate theheader.php
file.Add Meta Tags: Once you have located the
header.php
file, now it’s time for you to add the meta tag. You’ll have to add your meta tag in the<head>
section. Below is the complete code for it:
<meta name="description" content="Your page description here">
<meta name="keywords" content="keyword1, keyword2, keyword3">
- Save Changes: Once you have changed the meta tag, save changes by clicking on the update file button.
Note: Never make changes in your parent theme as when you edit the parent theme, new updates will overwrite your changes. To avoid this, always use a child theme.
Adding Meta Tags Using the functions.php
File
You can also edit the meta tags for your website through the functions.php
file. Let’s have a look at how to do so:
Access the
functions.php
File: Accessing thefunctions.php
file is the same as accessingheader.php
. First, go to Settings in Appearance and click on Theme File Editor. There you can find thefunctions.php
file on the right-hand side.Add Meta Tags with PHP: Add the following PHP code to insert meta tags:
function add_custom_meta_tags() {
echo '<meta name="description" content="Your page description here">';
echo '<meta name="keywords" content="keyword1, keyword2, keyword3">';
}
add_action('wp_head', 'add_custom_meta_tags');
- Save Changes: Once you’re done with the changes that you want to do, save and update the file.
Tip: Always back up your website before making changes to functions.php
, as errors in this file can break your site.
How To Add Meta Tags in WordPress Using Plugins
If you’re not comfortable with coding, then worry not—WordPress also provides a flexible approach to this issue. WordPress has several SEO plugins that allow you to add and manage meta tags without even looking at the code.
Add Meta Tags Using Yoast SEO
Yoast SEO is one of the most popular SEO plugins for WordPress, offering an easy way to manage meta tags.
Install Yoast SEO: First, go to the Plugins section of your WordPress and search for Yoast SEO. Then click on the Install button and activate it.
Add Meta Tags: Open the edit window of the page and scroll down to reach the Yoast SEO meta box. Enter the focus key phrase and meta descriptions in the appropriate fields.
Save Changes: Update your post or page to save the meta tags.
Adding Meta Tags to WordPress Using All in One SEO (AIOSEO)
Another great option is the All in One SEO plugin, which offers comprehensive meta tag management.
Install AIOSEO: Go to the Plugins section of your WordPress and search for All in One SEO. Click on the Install button and then activate it.
Configure Meta Tags: Navigate to All in One SEO General Settings. After that, scroll down to the meta tag sections and enter your desired meta tags. Click on the Save button to save changes.
Suggested Read:
Adding Meta Tags Using Meta Tag Manager
Meta Tag Manager is another famous plugin for WordPress. It is a dedicated plugin for handling meta tags.
Install Meta Tag Manager: First, go to the Plugins section and search for Meta Tag Manager. After installing, click the Activate button to start its services.
Add Meta Tags: After activation, go to Settings of the Meta Tag Manager. Add your meta tags using the simple interface. Save the settings, and your meta tags will be applied across your site.
Adding meta tags in WordPress is an essential step for optimising your website’s SEO. Whether you choose to add them manually through code or use one of the many available plugins, ensuring that your site has the correct meta tags will help improve its visibility and relevance to search engines. Always consider backing up your site before making any changes, especially when editing core files. By following this guide, you’ll be well on your way to mastering meta tags in WordPress, helping your site to rank better and attract more visitors.