Sub topic 4
Writing a title tag around the keyword
This chapter assumes you can read basic HTML (the head and body sections and common tags). It also assumes you have seen a search results page and have already picked a primary keyword and judged the search intent for your page. Here you turn that keyword into a title tag that search engines can classify and people want to click.
What the title tag has to do
The <title> element sits inside <head>. It is not shown on the page itself. It appears in the browser tab, in bookmarks, in shared links, and most often as the blue headline of a search result.
A title serves two readers at once:
- The search engine uses it as a strong signal of what the page is about. It is one signal among many, not a ranking switch.
- The person scanning results uses it to decide whether this page answers their query. A title that ranks but does not get clicked wastes the ranking.
Write for the person first, and make sure the search engine can still read the topic from the same words. In practice the two goals rarely conflict, unless you repeat the keyword to please the engine.
A working formula
Most good titles follow one pattern: the keyword phrase, a modifier that names the page type or the benefit, and optionally the brand.
| Page type | Pattern | Example | Column |
|---|---|---|---|
| How-to guide | How to + keyword + qualifier | How to Repot a Snake Plant: Step-by-Step Guide | |
| List | Number + keyword + qualifier | 7 Low-Light Houseplants That Are Hard to Kill | |
| Product or category | Keyword + differentiator + brand | Ceramic Plant Pots, 6 to 12 Inch \ | Leaf & Co |
| Comparison | A vs B + deciding factor | Terracotta vs Plastic Pots: Which Is Better for Succulents? | |
| Definition | What is + keyword + short answer | What Is Root Rot? Causes, Signs and Fixes |
The qualifier is the part that separates your result from ten similar ones. "Step-by-Step Guide" promises a procedure. "Causes, Signs and Fixes" promises coverage. Choose a qualifier you can deliver on the page, because a title that overpromises produces quick returns to the results page.
Placing the keyword
Put the keyword phrase near the start of the title when it reads naturally. Early placement has two practical benefits. People scan the first words of a result, and if the title is shortened in the results, the start survives.
Two rules decide the details:
- Keep the phrase intact. "Repot a snake plant" matches the query better than "snake plant, repotting, how to". Searchers type phrases, and the title should contain the phrase, or something very close to it.
- Do not force an exact match. "How to Repot a Snake Plant" and "Repotting a Snake Plant" are both fine. Search engines understand inflections and close variants, so grammar should win over literal matching.
Use the keyword once. A second appearance in the title adds no information for the reader and starts to look like stuffing, which a later chapter covers in detail.
The title in code
Here is a title written with the formula above, along with its meta description. The description does not affect the title's job directly, but it often appears under the title and finishes the pitch.
<head>
<title>How to Repot a Snake Plant: Step-by-Step Guide</title>
<meta name="description" content="Learn when and how to repot a snake plant, which pot and soil to use, and how to avoid root damage.">
</head>Compare it with a weak version of the same page:
<!-- Weak: repeated keyword, skipped level, vague headings -->
<title>Snake plant | snake plant repotting | repot snake plant | best snake plant</title>
<h1>Snake Plant</h1>
<h4>Snake plant repotting tips snake plant</h4>
<h2>More</h2>The weak title has four problems:
- It repeats the same words four times.
- It uses pipes as separators between keyword variants rather than between meaningful parts.
- It does not say what kind of page this is.
- It makes the reader guess whether the page is a care guide, a shop, or a buying list.
The h1, h4 and h2 lines in that snippet are for later chapters. Here, look only at the <title> line.
Matching the title to intent
The qualifier comes from the search intent you identified earlier. The same keyword needs different titles for different intents:
- Informational ("repot snake plant"): name the format, such as guide, steps, or checklist.
- Commercial investigation ("best pots for snake plants"): name the criteria or the year, such as "tested" or "for small spaces".
- Transactional ("buy snake plant pot"): name the product, a concrete detail, and the brand.
If the top results for your keyword are all how-to guides and you title your page "Snake Plant Pots for Sale", you are claiming a page type the results page does not reward. Look at the live results and use their pattern as evidence, then write a title that is clearer or more specific than theirs.
Brand and separators
A brand suffix helps with recognition and trust, especially for well-known sites. It also costs characters. Follow these rules:
- Put the brand at the end, so the keyword stays at the front.
- Use one separator, such as
|or-, and use it the same way across the site. - Drop the brand on pages where space is tight. A clear topic is worth more than a repeated brand name.
- Leave the brand off the home page title only if the page is not about the brand, which is rare. A home page title is usually the brand plus a short description.
Every title must be unique
Each indexable URL needs its own title. Duplicate titles make pages look interchangeable, so searchers cannot tell them apart and the engine has less to go on when choosing which page fits a query.
Duplicates usually come from templates. A blog template that outputs only the site name, or a category page that reuses the same title across pagination, are typical causes. Fix them by building the title from page-specific data, such as the product name or the article headline.
Checking a draft with a script
Before publishing, a quick check catches the mechanical errors. This script uses only the Python standard library. It extracts the <title>, reports the number of characters, and measures where the keyword appears and how often.
from html.parser import HTMLParser
class TitleFinder(HTMLParser):
def __init__(self):
super().__init__()
self.in_title = False
self.titles = []
def handle_starttag(self, tag, attrs):
if tag == "title":
self.in_title = True
self.titles.append("")
def handle_endtag(self, tag):
if tag == "title":
self.in_title = False
def handle_data(self, data):
if self.in_title:
self.titles[-1] += data
def report(label, html, keyword):
finder = TitleFinder()
finder.feed(html)
if len(finder.titles) != 1:
print(f"{label}: expected 1 title tag, found {len(finder.titles)}")
return
title = " ".join(finder.titles[0].split())
lower = title.lower()
key = keyword.lower()
print(
f"{label}: {len(title)} chars, "
f"keyword at {lower.find(key)}, keyword count {lower.count(key)}"
)
weak = "<title>Snake plant | snake plant repotting | repot snake plant | best snake plant</title>"
better = "<title>How to Repot a Snake Plant: Step-by-Step Guide</title>"
report("weak", weak, "snake plant")
report("better", better, "snake plant")Running it prints:
weak: 74 chars, keyword at 0, keyword count 4
better: 46 chars, keyword at 15, keyword count 1The numbers show that the weak title uses the phrase four times in 74 characters. The better title uses it once, in 46 characters. A position of 15 is fine here because "How to Repot a" comes first and reads naturally. The script also flags pages with zero or several <title> tags, which is a real fault in templated sites.
A character count is only a rough proxy for how a title displays. The next chapter explains why display width is measured differently and how truncation works.
The drafting process
The steps below turn a keyword into a final title. Run through them for each page.
Common errors
- Keyword repetition. Listing variants separated by pipes. Write one phrase and a qualifier instead.
- Keyword only. A title that is just "Snake Plant" gives no page type or reason to click.
- Clickbait qualifiers. "Ultimate" and "Best Ever" claims the page does not back up lead to quick returns to the results page.
- Same title everywhere. Template defaults that put the site name on every page.
- Title and page disagree. The title promises "7 pots" and the page shows four. Searchers notice, and so can the engine.
- Missing or multiple title tags. Each page should have exactly one
<title>, inside<head>. - Keyword far from the start. A long preamble pushes the topic to the end, where it is most likely to be cut off.
Review
A good title tag names the topic in the searcher's own phrase, states the page type or benefit, and is unique on the site. The keyword appears once, near the start, in grammatical form. The brand comes last and drops out first when space is short. Check the title with a script for mechanical faults, then read it aloud as a searcher would and ask whether you would click it.
Exercise
A page targets the keyword "compost bin for balcony" and the search results show mostly buying guides. Write a title tag of about 55 characters, state which pattern you used, and explain one thing you avoided.
Show answer
Example: "Best Compost Bin for a Balcony: 6 Tested Options" (about 49 characters). It uses the list pattern: the keyword phrase near the start plus a number and a qualifier ("Tested") the page must deliver. It avoids repeating the keyword or listing variants such as "balcony compost | apartment compost bin". Any title that has the phrase once near the start, matches the buying-guide intent, and makes a promise the page can keep is acceptable.
Exercise
Run the script above on <title>Plant pots | Plant pots for sale | Buy plant pots online | Leaf & Co</title> with the keyword "plant pots". What does the report show, and what two changes would you make?
Show answer
The title is 71 characters long, the keyword is at position 0, and the count is 3, so it is repeated. The changes are to use the phrase once and to add a concrete qualifier. For example: "Ceramic Plant Pots in 6 Sizes | Leaf & Co" keeps the keyword near the start, names a detail, and ends with the brand.