How to Add Meta Tags in WordPress Without an SEO Plugin

Adding meta tags to your WordPress website is an essential step in search engine optimization (SEO) to improve your search engine ranking and drive more traffic to your site. Meta tags provide information about your website to search engines, helping them understand and organize your content effectively.

While a popular SEO plugin like Slim SEO, Yoast SEO, or Rank Math can help. you to add meta tags to WordPress websites, there are alternative methods to achieve this without relying on SEO plugins.

By manually adding meta tags to your WordPress site, you have more control over the content that appears in search engine results and can optimize it for better search engine ranking. In this article, we will guide you through a few simple steps of adding meta tags to your WordPress site without using SEO plugins.

What are meta tags?

Meta tags are snippets of HTML code that provide information about a webpage. By adding meta tags such as meta title (also called SEO title), meta description, meta keywords, and Open Graph tags you give search engines valuable information about your website's purpose and content. This enables search engines to match your site with relevant search queries and display a well-written meta description in search results, increasing the likelihood of attracting potential visitors.

Meta description tag is displayed as the featured snippet on SERPs.
Meta description tag is displayed as the featured snippet on SERPs.

There is information about the web page or post that meta tags can provide to search engines, such as the author, keywords, description, type of document, copyrights, and other core information which you think is relevant to your page. But the most important meta tag is the meta description tag. Below is a sample of meta tags output in the HTML format:

<title>Slim SEO - Fast & Automated WordPress SEO Plugin</title>
<meta name="description" content="A lightweight and automated WordPress SEO plugin that helps you optimize your websites for Google and get high rankings with a few clicks.">
<meta name="robots" content="max-image-preview:large, max-snippet:-1, max-video-preview:-1" />
<meta property="og:title" content="Slim SEO - Fast &amp; Automated WordPress SEO Plugin">
<meta property="og:type" content="article">
<meta property="og:image" content="https://wpslimseo.com/wp-content/uploads/2023/06/slim-seo.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Slim SEO">
<meta property="og:description" content="A lightweight and automated WordPress SEO plugin that helps you optimize your websites for Google and get high rankings with a few clicks.">
<meta property="og:url" content="https://wpslimseo.com/">
<meta property="og:locale" content="en_US">
<meta property="og:site_name" content="Slim SEO">
<meta property="article:published_time" content="2019-05-06T15:15:18+00:00">
<meta property="article:modified_time" content="2023-06-26T02:48:50+00:00">
<meta property="og:updated_time" content="2023-06-26T02:48:50+00:00">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://wpslimseo.com/wp-content/uploads/2023/06/slim-seo.png">
<meta name="twitter:site" content="slimseo">

Why are meta tags necessary for SEO?

Optimizing meta tags is one of the most important aspects of the on-page SEO process. The better you optimize them, the higher the chances of your website gaining favor with search engines.

Search engine bots crawl meta tags and the content of your articles to find relevant information for users. If your meta tags contain important keywords, your page or post will rank higher in search results. Thus, it's essential to keep your meta tags concise and keyword-rich. Ideally, place the keyword at the beginning of the description for optimal SEO results.

Additionally, since meta tags appear on search result pages, it's crucial to optimize them well and incorporate compelling call-to-action words within the content. That way, you can encourage potential readers to click through to your site, increasing the click-through rate.

Why not use SEO Plugins for adding meta tags?

There are several reasons why it is beneficial to avoid using SEO plugins in your WordPress site. Firstly, these plugins often come with features that duplicate what is already available in WordPress itself (such as XML sitemap). This can lead to unnecessary clutter and confusion in your website's backend.

Secondly, these WordPress SEO plugins can sometimes have bugs or conflicts with other plugins or themes, which can cause technical issues and hinder your site's performance. By avoiding these plugins, you can minimize the risk of encountering such problems.

Another reason to avoid using an SEO plugin is the desire for greater control over your SEO efforts. Plugins may offer a wide range of features, but they may not align with your specific needs or preferences. By manually adding meta tags and optimizing your website without relying on plugins, you can have full control over the SEO elements that matter most to you.

Last but not least, many WordPress SEO plugins are too complicated for normal users. And if you just want to manage your meta tags, they might be too much and sometimes, too bloated. This is the reason why we started Slim SEO - a lightweight and automated SEO plugin for WordPress where the configuration is minimal.

How to add meta tags to WordPress without plugins

To manually add meta tags to your WordPress site, you'll need to add a snippet to your theme's functions.php file.

You can do that by editing the file directly inside WordPress admin, or via a file manager on your control panel in your host (like cPanel). In this article, we'll show you how to do that directly in the WordPress admin.

Note: it's recommended to use a child theme to add custom code. Editing an active theme can cause an error if you're not sure what's wrong.

To start, go to your WordPress admin > Appearance > Theme File Editor and select the Theme Functions (functions.php) file on the right:

Edit the theme functions file inside WordPress admin
Edit the theme functions file inside WordPress admin

Add the following code to the bottom of the file:

function slim_seo_meta_description() {
    global $post;
    if ( is_singular() ) {
        $description = wp_strip_all_tags( $post->post_content );
        $description = strip_shortcodes( $description );
        $description = str_replace( [ "n", "r", "t" ], ' ', $description );
        $description = mb_substr( $description, 0, 160 );
        echo '<meta name="description" content="', esc_attr( $description ), '">';
    }
    if ( is_home() ) {
        echo '<meta name="description" content="', get_bloginfo( 'description' ), '" />';
    }
    if ( is_category() ) {
        $description = wp_strip_all_tags( category_description() );
        echo '<meta name="description" content="', esc_attr( $description ), '">';
    }
}
add_action( 'wp_head', 'slim_seo_meta_description' );

Please note, the above lines of code should be added before closing tags of php ?>.

After adding the code, click on the "Update File" button to save your changes. It is crucial to ensure that you do not delete or modify any other code within the functions.php file while making these changes.

If you need to add the meta keywords tag, add the code below to the functions.php file. Please note that the meta keyword tag is deprecated and not widely used by search engines. So use it with your consideration.

function slim_seo_meta_keywords() {
    echo '<meta name="keywords" content="your keywords here, separated by commas" />';
}
add_action( 'wp_head', 'slim_seo_meta_keywords' );

So, you have finished adding meta tags to your WordPress website without plugins.

To ensure that the meta tags have been added correctly, you can check the source code of your website again or use a browser extension like "SEO Meta Tags Analyzer" to validate the presence of the meta tags.

Disadvantages of adding meta tags manually

While this approach allows you to have complete control over your SEO and customize your meta tags according to your specific requirements, it requires you to regularly update your meta tags based on your content and target keywords to keep them updated with your SEO strategy.

Additionally, if you plan to choose a new theme, you need to repeat the same steps in functions.php in your new theme to make it works again. Not remembering this can cause missing them on your website and cause a drop in your site traffic.

And finally, editing a theme directly is risky and not recommended. You can easily miss a character by copying and pasting (like a comma, a quote, etc.) and that can break your website. If that's what you need to do, it's better to ask someone familiar with coding to help you.

What if I need more SEO features like XML sitemap, schema, or redirection?

If you need more SEO features, you can either choose to do that manually, like you already did above with meta description and meta keywords, or use an SEO plugin like Slim SEO, Yoast SEO, or Rank Math.

The question here is which WordPress SEO plugin does it best while not sacrificing your website performance. You might want to choose an SEO plugin that is:

  • Lightweight, has no bloat, and runs fast
  • Minimal, and doesn't have too many options for configuration which might confuse you
  • Has the features you need and better if you can enable and disable the features you don't need
  • Doesn't have too many ads

In this case, we recommend Slim SEO, the plugin we develop for the exact reasons above. It is a lightweight and automated SEO plugin for WordPress. All you need to do is install and activate it. The plugin will do all the SEO tasks automatically for you. Of course, it has support for XML sitemap, schema (structured data), redirection, and more.

To learn more about Slim SEO, please check out the homepage.

Conclusion

Adding meta tags is an important on-page SEO step to improve your search engine appearance and increase CTR. In this article, we've shown you how to do that manually without using any plugins. This method helps you control what is displayed to search engines and what is not.

Because it involves coding, it's recommended that you understand coding a little bit. Otherwise, you might need help from a developer, or use a lightweight SEO plugin like Slim SEO.

Leave a Reply

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