Optimize Your Title Tags for Search Engines without plugin

To ensure search engines understand the content of your pages clearly, it’s crucial to include a properly formatted title tag for all page templates. This includes not only posts but also paginated archive pages.

Typically, title tags are generated by your theme or CMS. However, in many cases, they may not be created properly, especially for archive pages with pagination.

For example, the URL

example.com/category/mycategory/page-2/
might generate a title tag like:

<title>Category MyCategory - Site Name</title>

Instead, it should look like this for better clarity and SEO:

<title>Category MyCategory | Page 2 - Site Name</title>

 

Here, we will guide you through how to ensure your title tags are properly generated, step by step:

What is a title tag?

A title tag is an essential HTML element that defines the title of a web page, displayed in browser tabs and search engine results. Found in the

<head>
section of a page’s HTML, it plays a critical role in SEO and user experience. For example:

<title>My Current Post - Site Name</title>

The title tag is not the same as the visible title seen in the page’s content. It is part of the HTML output, typically read by search engine crawlers. The title tag should closely match the visible content title, excluding additions like the “site name.”

An optimized title tag improves click-through rates by providing clear, concise, and relevant information about the page’s content.

 

Ensure the title tag is generated correctly

To verify that the title tag is being generated correctly across various pages such as the front page, blog (posts page), single post, single page, category, tag, date-time archive, and author archive, you need to inspect the HTML output of each page.

1. Open Developer Tools (in most browsers, press F12 or right-click and select Inspect Element).

2. Locate the title tag in the

<head>
section. This will be part of the HTML structure of your page, which typically looks like this:

<!doctype html>
<html>
<head>
<title>my title tag</title>
<!-- other html/head tags... -->
</head>
<body>
<!-- page content -->
</body>
</html>

Title tag vs Content title

Generate title tags for standard pages

To ensure title tags are generated for all standard pages, insert the following PHP code before the closing </head> tag in your

header.php
or similar theme file:

<?php
if (is_front_page()) { ?>
<title>Site Name</title>
<?php }
if (is_singular() && !is_front_page()) { ?>
<title><?php the_title(); ?> | Site Name</title>
<?php }
if (is_archive() || is_home()) { ?>
<title><?php wp_title('-', true, 'right'); if ($paged > 1) { echo ' Page ' . $paged; } ?> | Site Name</title>
<?php }
?>

This code ensures that title tags are generated correctly for the front page, single posts, and archives with pagination.

Specific Title Tags for Different Page Types

Front Page:

<?php
if (is_front_page()) { ?>
<title>Site Name</title>
<?php } ?>

Blog with Pagination:

<?php
if (is_home()) { ?>
<title><?php wp_title('-', true, 'right'); if ($paged > 1) { echo ' Page ' . $paged; } ?> | Site Name</title>
<?php }
?>

Archive Pages (Category, Tag, Author, Date-time archives, etc.):

<?php
if (is_archive()) { ?>
<title><?php wp_title('-', true, 'right'); if ($paged > 1) { echo ' Page ' . $paged; } ?> | Site Name</title>
<?php }
?>

Single Posts and Pages:

<?php
if (is_singular() && !is_front_page()) { ?>
<title><?php the_title(); ?> | Site Name</title>
<?php }
?>

Generate title tags for Blog & Archive pages with pagination

If your theme generates a title tag for archive and blog pages but not for paginated pages, consider disabling automatic title tag generation. Here are a few methods you can use:

Method 1: Modify Theme Files

You can directly edit your theme files (usually

header.php
or
functions.php
) and remove or modify functions like:

add_theme_support('title-tag');

Method 2: Use a Filter to Remove Title Tags

Add the following filter to your

functions.php
to remove or customize title tags:

add_filter('pre_get_document_title', '__return_empty_string');

Method 3: Customize Document Title Parts

To customize the title generation process for archive or blog pages, use this filter:

add_filter('document_title_parts', function($title) {
if (is_archive() || is_home()) {
$title['title'] = ''; // Or set a custom title
}
return $title;
});

Final Considerations

If none of the code snippets work due to your theme’s structure, consider contacting the theme developer or reviewing the theme documentation to see how title tags are generated. Each theme may use a different method for generating meta tags, so it’s crucial to understand the theme’s specific implementation.