how to add meta tags in wordpress without plugin
Have you properly added meta tags to your WordPress website?
Meta tags are the elements that are crucial for website SEO to get a better search engine ranking.
But the problem is,
WordPress doesn't have meta tags by default. It is the website owner's responsibility to add to the website.
Search engine crawler fetches these meta tags and identifies what a website or any specific page is all about.
So, optimizing your website for meta tags may have a significant improvement in SERP ranking. And better ranking means more traffic and more website revenue.
In this article, I will guide you on how to add meta tags to a WordPress website without any plugin.
But before you proceed,
I'll suggest you keep a backup of your WordPress site so that if anything goes wrong, you'll be able to recover your website data again.
Let's get started.
How To Add Meta Tags In WordPress Without Plugin
1. Head over to Appearance>Theme Editor
First of all login to your WordPress dashboard and click on Theme Editor followed by Appearance on the left pan.
2. Click On Theme Functions (header.php) File
Once you click the Theme Editor, you'll see the backend of the activated theme of your WordPress site.
Here, on the right pan under Theme Files, click on Theme Function (function.php) file. This will open the function PHP file of the activated theme.
3. Add The Code Into The function.php File of style
Here on the theme function file, you'll have to add the meta tags. So, first, copy the code from the below box.
function add_meta_tags() { global $post; if ( is_single() ) { $meta = strip_tags( $post->post_content ); $meta = strip_shortcodes( $post->post_content ); $meta = str_replace( array("\n", "\r", "\t"), ' ', $meta ); $meta = substr( $meta, 0, 160 ); $keywords = get_the_category( $post->ID ); $metakeywords = ''; foreach ( $keywords as $keyword ) { $metakeywords .= $keyword->cat_name . ", "; } echo ' <meta name="description" content="' . $meta . '" />' . "\n"; echo ' <meta name="keywords" content="' . $metakeywords . '" />' . "\n"; } } add_action( 'wp_head', 'add_meta_tags' , 2 ); Now, scroll down the function.php file and move to the bottom where the HTML codes end.
And paste copied meta tags code over here as you can see in the below image.
Once you pasted the code in the function.php file, you're done.
What this code does now is that it automatically fetches the starting 160 characters from the first paragraph of any post and page and will show it as a description.
And it fetches the post or page category and will show as a meta keyword.
Important Note:
Always remember, you'll have to repeat the whole process and paste the code again if you switch your WordPress website to a new theme.
Now you've successfully added the meta tags to your WordPress site without using any SEO plugin.
But before you make this change, let's discuss a little bit about what actually meta tags are, their elements, why you need meta tags, and many more.
Let's dive into it.
What Are Meta Tags
WordPress meta tag is a bit of HTML code that includes website core information such as title, description, and keyword.
A user has to add this snippet of HTML code into the website header that tells the search engine about any post or page content.
However, this meta tag is only accessible for search engines and browsers. A visitor can't see the meta tags because they don't appear on the front end of the website.
A user can see the meta tags of any website in SERP something like:
The 3 Elements Of Meta Tags
Website meta tag has three main elements, Title, Description, and Keyword. So, you have to use these meta tags smartly to get the most benefit out of them.
1. Meta Title
A meta title tag is the title of any page or post that Google and any search engines show in search results.
Here is an example of a meta title:
<head><title>This is the title of the page.</title></head> Optimizing the meta title is very essential because it is the first thing that a user focuses on in SERP when they search for anything in the search engine.
And if they found the title is exactly what or relevant about they looking for, they just click on the title, visit the page, and gives their crucial time on that page.
And you already know, more click-through rate means better ranking. And better ranking means more organic traffic.
So, always make the title eye-catchy and more enticing to the user to get more clicks.
A user sees the meta title of any web page in SERP something like:
2. Meta Description
A meta description tag is a summary or short paragraph that is written to give a little information about any particular page.
However, Google no longer gives importance to meta description from an SEO perspective. But still, it is essential for users.
When a user searches for any topic on Google, they see the meta description of the resulted pages to know a little more about the page.
And if he/she found the meta description is relevant to what they looking for, the result gets clicked.
This is why you should optimize meta descriptions on every page by putting a relevant summary about the page.
Here is an example of meta description:
<meta name="description" content="This is the meta description of a web page or post." /> Users will see the meta description in SERP something like:
3. Meta Keywords
Meta keywords are the terms or focus topics of your web page that you put in the description. But, it is not necessary to include them always in the description.
It's up to you whether you want to include meta keywords or not. And it will not have any bad impact on your website SEO.
But most SEO experts and bloggers suggest including meta keywords in the description because it has some benefits for on-page SEO.
Meta keywords appear bold in meta description which looks something like:
Why Are Meta Tags Necessary?
1. Better For SEO
However, keywords, title, and description are not the direct factors that Google uses to rank any pages, still optimizing a website for meta tags is beneficial for website SEO.
Many expert SEOs and professional bloggers suggest optimizing websites for these tags because it has importance for on-page SEO.
So, you should add meta tags to your WordPress site home page and all posts.
2. Helps Search Engines Index Pages Easily
Having meta tags placed in the header section of pages helps search engines easily crawl and identify what the web page is about.
So, the more easily the crawler fetches the content, the more quickly it will index the pages on Google.
3. Helps In Better Ranking
When you include the focus keywords in the meta title and in the description, your web page gets a better search engine ranking.
This is because Google or any other search engine also read through the title and description to identify the relevancy of the topic that a user is searching for.
So, if search engines found the relevant topic in the meta tags, they promote the content in the SERP to answer the reader.
Why Add Meta Tags, Description, & Keywords Without Any Plugin
The main question is why add meta tags without using any third-party plugins when we have some powerful SEO plugins out there?
Here are the advantages of adding meta tags without any plugins:
- The first benefit is that you don't have to depend on any particular SEO plugins.
- Since you don't use an extra SEO plugin, this means it can have a bit of improvement in your website performance.
- When you add meta tags manually, you avoid useless scripts being called that generated by other SEO plugins.
Cons Of Adding Meta Tags In WordPress Without Plugin
- The main disadvantage of adding meta tags without a plugin is hard work. This means if your site is big, then it will require a lot of work.
- This process requires a bit of HTML knowledge. It is because making changes to the source code may have a big loss in case of any coding error.
- You'll have to update the meta tags again if you switch to a new WordPress theme.
Now that you've known how much meta title, meta description, and meta keywords are important for any website.
Conclusion
That is how you can add meta tags to the WordPress website without using any plugin.
However, I recommend not doing this process manually and use dedicated WordPress SEO plugins such as Rank Math SEO or Yoast SEO.
These plugins have amazing on-page SEO benefits along with keyword tracking and some technical SEO optimization.
If you found this article helpful, then make sure to share it on social media and in the blogging community for others.
And if you have any kind of suggestion or query about this article then write them in the below comments.
Articles you may also find useful:
- Blogger VS WordPress: Which Is Best For Making Money & Why?
- Start Your Own WordPress Blog and Make Money in 2021
how to add meta tags in wordpress without plugin
Source: https://www.bloggingprolab.com/how-to-add-meta-tags-in-wordpress-without-plugin/
Posted by: mahartress1947.blogspot.com

0 Response to "how to add meta tags in wordpress without plugin"
Post a Comment