On-Page SEO: Titles, Descriptions, Headings and URLs
Write clear titles, meta descriptions, headings, URLs and image text, and audit a page with a short program that reads it like a crawler.
In this lesson you will
- Write a strong title tag
- Write a helpful description
- Build a clean heading outline
- Audit a page with code
About 16 minutes
The tab that says Home
Tom runs a small cafe. He opens his site and notices the browser tab simply says ‘Home’. So does the tab for his menu page, and for his contact page. He never gave them real titles. When he searches for his own cafe, Google shows a result headed ‘Home’, with no description underneath. A stranger would have no idea what it is. This is the most fixable problem in beginner SEO, and fixing it takes about ten minutes per page.
What on-page SEO means
On-page SEO is everything you control inside a single page: its title, description, headings, text, images and web address. It sits between lesson 3 (choosing the topic) and lesson 5 (writing the content). Get these basics right on every page and you have done more than many busy sites ever do.
The title tag
The title tag is the page’s name. It appears on the browser tab and is usually the blue headline of the search result. It is the single most important line of text on the page for both searchers and search engines. A good title says clearly what the page is, includes the main phrase near the start, and ends with your brand name if there is room.
Keep titles to roughly 50 to 60 characters as a guide. Search engines actually cut titles by pixel width, not by character count, so a title with narrow letters can run longer, and one with wide letters may be cut sooner. Search engines also sometimes rewrite titles they think are poor. The best defence is to write a clear title that fits and truly describes the page. Give every page a different title.
The meta description
The meta description is a short summary of the page that search engines may show under the title. Google has said it does not use the description to rank pages directly, but a clear, honest one can persuade people to click, and that matters. A common guide is roughly 120 to 160 characters. There is no official number, and the engine may show a different snippet taken from your page if that fits the search better. Write it as a friendly promise, and then keep the promise.
Headings: the outline of the page
Headings are the page’s outline. The H1 is the main heading, and a page normally has just one. It should match the title in meaning, though it need not be identical. The H2 headings divide the page into sections, and H3 headings divide those further. Think of a book: one title, then chapters, then sub-chapters. Headings help people skim and help engines understand structure. Use them for structure, never merely to make text bigger.
URLs and image text
A web address should be short, readable and in lowercase, with words separated by hyphens: for example /sourdough-starter rather than a string of numbers. Choose it once and avoid changing it later, because every change risks breaking links. Every meaningful image should also have alt text, a short description of what the picture shows. It helps people who use screen readers and gives engines context.
Audit a page with code
Here is a small program that reads a page the way a crawler does and reports what it finds. It uses only Python’s built-in HTML reader. We run it on a weak page and on an improved version of the same page. The output is real.
from html.parser import HTMLParser
class Audit(HTMLParser):
def __init__(self):
super().__init__()
self.title, self.desc = "", ""
self.h1, self.h2 = [], []
self._in_title, self._open = False, None
def handle_starttag(self, tag, attrs):
a = dict(attrs)
if tag == "title":
self._in_title = True
elif tag == "meta" and a.get("name") == "description":
self.desc = a.get("content", "")
elif tag in ("h1", "h2"):
self._open = tag
getattr(self, tag).append("")
def handle_endtag(self, tag):
if tag == "title":
self._in_title = False
if tag in ("h1", "h2"):
self._open = None
def handle_data(self, data):
if self._in_title:
self.title += data
if self._open:
getattr(self, self._open)[-1] += data
def report(label, page):
a = Audit()
a.feed(page)
print(label)
print(f" title ({len(a.title)} chars): {a.title}")
print(f" description: {len(a.desc)} chars")
print(f" h1 count: {len(a.h1)} h2 count: {len(a.h2)}")
return a
before = """<html><head><title>Home</title></head><body>
<h1>Welcome</h1><h1>Sourdough</h1><p>Bread.</p></body></html>"""
after = """<html><head>
<title>Easy Sourdough Bread for Beginners | Maya's Bakery</title>
<meta name="description" content="Bake your first sourdough loaf at home. Maya shares a simple starter, a clear timetable and fixes for flat, dense bread.">
</head><body>
<h1>Easy Sourdough Bread for Beginners</h1>
<h2>What you need</h2><h2>Make the dough</h2><h2>Fix a flat loaf</h2>
</body></html>"""
report("BEFORE", before)
report("AFTER", after)
BEFORE
title (4 chars): Home
description: 0 chars
h1 count: 2 h2 count: 0
AFTER
title (50 chars): Easy Sourdough Bread for Beginners | Maya's Bakery
description: 120 chars
h1 count: 1 h2 count: 3
The first page had a title of 4 characters (‘Home’), no description, and 2 H1 headings. Nobody could tell what the page was about. The improved page has a title of 50 characters that names the topic and the brand, a description of 120 characters, exactly 1 H1 and 3 H2 headings that give the page a clear outline. The title length counts every character including spaces and the vertical bar.
Run this idea on your own pages. You do not need the code: view the page source in your browser and look for the title and meta description lines. If either is missing, or the same on several pages, you have found your first job.
Writing titles for search engines only, such as ‘Bread | Bread Recipe | Best Bread | Bread UK’. This reads badly and gains nothing. Write the title for a person and make sure the main phrase is in it once.
If you use WordPress, an SEO plugin or the theme usually provides boxes for the title and description of each page. The place to find them differs by plugin and theme, so look for a section named after the plugin below your editor.
Practice for this lesson
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
Where does the title tag usually appear?
- Only in the footer
- Only in images
- On the browser tab and search result
- Inside the sitemap
The title shows on the tab and is normally the headline of the search result.
How many H1 headings should a normal page have?
- None
- Five
- As many as possible
- One
One H1 states the main topic, like the title of a book.
Why are character counts only a guide for titles?
- Titles have no limit
- Search engines cut titles by pixel width
- Counts are illegal
- Only images count
Narrow and wide letters take different space, so the cut-off varies and engines may also rewrite titles.
What does a good meta description mainly help with?
- Fixing broken links
- Speeding up the page
- Persuading people to click
- Hiding the page
Google has said it is not a direct ranking signal, but a clear one can lift clicks.
Which URL is best?
- /sourdough-starter
- /page?id=7734
- /Sourdough_Starter
- /SOURDOUGH STARTER
Short, lowercase words joined by hyphens are readable for people and engines.
Summary
- The title is the most important single line on the page.
- Keep one H1 and use H2 headings for sections.
- Descriptions do not rank pages directly but can earn clicks.
- Short, lowercase, hyphenated URLs are best.
Questions
Should the title and the H1 be identical?
They can be, but they do not have to be. They should mean the same thing. The title is written for the search result and tab, and the H1 for readers on the page.
What if Google shows a different title or description than I wrote?
Engines sometimes rewrite them to fit the search better. Improve by making yours clear, accurate and on topic, and make sure the page itself says what the title promises.
Do I need to change old URLs to be keyword friendly?
Usually not. Changing an old address can break links and lose traffic unless you set up proper redirects. Make new URLs clean from the start.
