On-Page SEO: How to Optimize for Robots and Readers

Ryan Law
Ryan Law is the Director of Content Marketing at Ahrefs. Ryan has 13 years experience as a writer, content strategist, team lead, marketing director, VP, CMO, and agency founder. He's helped dozens of companies improve their content marketing and SEO, including Google, Zapier, GoDaddy, Clearbit, and Algolia. He's also a novelist and the creator of two content marketing courses.
Article Performance
Data from Ahrefs

The number of websites linking to this post.

This post's estimated monthly organic search traffic.

On-page SEO is the process of optimizing blog posts and website pages to improve their search rankings.

On-page SEO is important because small changes to your page can have a big impact on its rankings and traffic.

Here’s an example of one of our blog posts climbing 7 places in the search results after changing a single word in the title:

Tip
On-page SEO refers to the improvements we can make directly on our page. Anything that helps with search performance but can’t be changed directly on our page is called off-page SEO.

On-page SEO is like icing on a cake. To get the most from on-page SEO, you need helpful, accurate content that matches the intent of the keyword you’re targeting. (We have a guide on this topic in the previous chapter.)

With that taken care of, here are some practical on-page tweaks that can help you rank higher and get more search traffic performance:

Including your target keyword within key elements of your page will help Google (and your readers) understand what the page is about:

  • Page title
  • URL
  • Main header (H1)
  • Subheaders (some of your H2s, H3s, etc.)
  • Intro paragraph

Or put another way: it would be weird to write an article on “brewing espresso” without mentioning the phrase “brewing espresso” in the title or introduction.

It helps to include some exact-match keywords in these important locations, but Google is also smart enough to recognize synonyms and related keywords. If your target keyword is three or four words long, you don’t need to include it as an exact match every time.

There’s no magic keyword density to aim for, and including lots of keywords in unnatural ways can actually hurt your performance (it’s called keyword stuffing).

Your goal here is to clearly and consistently tell Google (and your readers) precisely what your article is about.

HTML header tags help Google understand the content on your pages, and break it up into logical, easily skimmed sections.

Header tags look like this—<h2>Header goes here</h2>—in your page’s code. You can use the Ahrefs toolbar to quickly see how header tags are used on a page:

As a general guide, try to:

  • Use one <h1> tag per page.
  • Use <h2> tags for your page’s main points. 
  • Use <h3> tags (and beyond) for sections that support your main points, like examples or related ideas.

As an added benefit, good use of subheadings will improve the readability of your content, making it easier to see, at a glance, what each section is about:

Title tags are often the main piece of information used to decide which search result to click on. More often than not, that hinges on having a great title.

Google rewrites title tags 61.6% of the time (most often for titles that are very short or very long). But these are usually small changes, so it’s worth spending time making your title as compelling as possible.

Here are a few tips for writing titles:

  • Keep them short—under 70 characters is best to avoid truncation.
  • Match search intent – tell searchers you have what they want.
  • Harness the curiosity gap—but don’t create misleading clickbait that isn’t reflective of the article’s contents.
  • Include the keyword—or a close variation if it makes more sense.
  • Include the year for topics that demand freshness—like tax allowance 2024.
  • Do something to stand out—show a sense of humour, or respond to other articles in the SERP.
  • If in doubt, use the ABC formula—adjective, benefit, confidence booster.

You should set a title tag on every indexable page. If you like, you can use Ahrefs’ Site Audit to find pages with title tag issues like being empty or too long. Once you’ve signed up and crawled your site (it’s free), go to the Content report to check for issues.

Here we can see 226 page titles that are too long, and at risk of getting truncated:

Meta descriptions aren’t a ranking factor, but they can bring more clicks and traffic. This is because Google uses them for the descriptive snippet in the search results 37.22% of the time. The rest of the time, they use other content from the page.

For that reason, there’s no ned to obsess over crafting perfect meta descriptions for every page. Just focus on writing good ones for important pages, like your homepage or those that get lots of search traffic. Here are a few writing tips:

  • Keep them short—under 160 characters is ideal.
  • Expand on the title tag—include extra information that your title doesn’t contain.
  • Match search intent—double down on what searchers want.
  • Use an active voice—address the searcher directly.
  • Include your keyword—Google often bolds these in the results.

To speed up this process, try our free AI meta description generator. Describe your page, choose a desired writing tone, and hit “generate”.

The tool will generate a few options for you to use or remix to your heart’s content:

It’s helpful to use a short, descriptive URL structure highlighting the core topic of the page. As Google explains in its SEO starter guide:

“Parts of the URL can be displayed in search results as breadcrumbs, so users can also use the URLs to understand whether a result will be useful for them.”

We recommend using your target keyword as the URL slug, like we do throughout the Ahrefs blog:

Page TitleTarget KeywordURL Slug
SEO Agency Software (My Tried and Tested Tools)seo agency software/blog/seo-agency-software/
Franchise SEO: Local and National Growth Strategies for Franchisesfranchise seo/blog/franchise-seo/
SEO Trends 2024: Separating Fact From Fictionseo trends/blog/seo-trends/
How to Promote Your Blog (There Are Only Three Ways)how to promote your blog/blog/how-to-promote-your-blog/

Adding your keyword to your URL won’t magically boost search performance, but it will build the reader’s confidence that your page is relevant to their query.

(And make your life easier when you come to update your old content and can’t remember what the target keyword was.)

When choosing your URL, it’s a good idea to:

  • Avoid including dates (unless they’re essential). /best-seo-tools-2024 makes sense this year, but it will send the wrong message to searchers if you want to update your article next year.
  • Don’t worry about function words. Words like for, and, or to can be safely left out of your URL.
  • Make URLs simple and readable. domain.com/article/keyword-research-guide is better than domain.com/2024/03/21/article-keyword-research.

If you have them, link to relevant pages on your website. Internal links help visitors navigate your website and increase the odds that they’ll find the information they need—but there are benefits for SEO too.

Internal linking helps search engines find all the pages on your website, understand what each page is about (and how they relate to one another), and highlight the pages you believe to be the most important. These links also help pass link authority between your pages.

When adding internal links:

  • Use relevant anchor text—but keep it natural and don’t keyword stuff your anchors.
  • Link to your most important pages, like your product and service pages, or your best blog posts.
  • Use the hub-and-spoke model to ensure that your most important “hub” pages receive the link authority they deserve.

You can use Google’s site: search operator to quickly find relevant pages to link to. Search your website for your target keyword (in brackets to find exact matches), and Google will show every indexed page that features the keyword:

Or you can automate the process using Ahrefs’ Site Audit:

  1. Go to the Internal link opportunities report
  2. Enter the URL of your newly-published page in the search box
  3. Choose “Source page” from the dropdown

Hit enter, and you’ll see a list of recommended internal linking opportunities.

For example, here the report is suggesting that I link from our post on toxic backlinks to our guide on bad links:

Learn about the ins and outs of internal linking in our full guide: Internal Links for SEO: An Actionable Guide.

Google says linking to other websites is a great way to provide value to your users

External linking is also a good idea whenever you want to cite information from elsewhere on the web, or send the reader to an authoritative third-party source of information.

We do this all the time on the Ahrefs blog:

Over time, some of your external links will break as the linked page is redirected or deleted, creating a bad user experience. You can find and fix these broken links using Site Audit: just set up a regular crawl of your website, and monitor the Pages with broken links issue in your crawls.

Images from your pages can rank in Google image search and send more traffic your way. You need to do three things to optimize them:

  • Compress your images. Compressing images makes file sizes smaller, leading to faster load times. Plenty of tools exist for doing this. ShortPixel is a good option.
  • Use descriptive filenames. Google says that filenames give them clues about the image’s subject matter.[9] So dog.jpg is better than IMG_859045.jpg. As a rule of thumb, be descriptive, be succinct, and don’t stuff keywords.
  • Use descriptive alt text. The main purpose of alt text is to improve accessibility for visitors who use screen readers, but Google also uses alt text (alternative text) to understand the subject matter of an image.[9] This is an HTML attribute that looks something like this: <img src=“https://yourdomain.com/puppy.jpg” alt=“puppy”>

You can use the Images report in Ahrefs’ Site Audit to check your site for images with missing alt text (and flag a host of other possible optimization opportunities, like oversized images):

You can often improve your ranking by filling any “content gaps” in your article: important information that other articles cover, but you don’t.

Adding new sections to include this missing information can help you rank for extra long-tail keyword variations and improve your ranking for your primary keyword.

In the image below, we can see an article called How to brew espresso ranking for 712 keywords, including terms like how to make espresso at home and espresso shot:

The Content Gap report In Ahrefs is designed to quickly show these opportunities. In the screenshot below, I’m comparing an article about how to make espresso (highlighted) with three competing articles:

Hit “Show keywords” and you can immediately see keywords that you don’t rank for, but your competitors do. In this example, we should probably add a section talking about the type of coffee that works best in espresso machines:

Our new Content Grader takes a different approach, using semantic analysis (analyzing the words on the page) to find topics covered by your competitor but lacking from your article.

Here, we just add our published article URL and the target keyword:

Content Grader identifies common topics, and scores each article based on how well it covers the topic:

Before making specific recommendations for topics to consider adding to our own article:

Google’s quality rater guidelines encourage authors to demonstrate “EEAT” in their content: expertise, experience, authoritativeness, and trustworthiness.

These guidelines are used by Google’s quality raters, and although they’re not a direct ranking factor, they give a clear indication of the type of content Google aims to reward in its search results. You can emphasize your EEAT in a few different ways:

  • Show relevant expertise in your author bio. This is especially important for so-called YMYL (Your Money or Your Life) topics: medical content should be reviewed by medical professionals, investment advice by accredited investors, and so on.
  • Include expert quotes. When your expertise isn’t enough to be authoritative on the subject, seek out quotes and feedback from people who are experts (especially in fields that require specific certifications and qualifications, like healthcare or accountancy).
  • Get hands-on with your topic. If you’re writing about brewing espresso, actually go and brew a few hundred shots. Reviewing free CRM software? Download, install, and spend a few hours with each option. If you aren’t willing to go to these lengths, there’s a good chance you’ll be beaten by someone who will.
  • Show evidence. Prove to readers (and Google) that you did the thing you’re talking about: add experience to your author bio, and include original photographs and videos of your experience.
Here’s an example of an author bio demonstrating relevant expertise for the article topic.

Featured snippets are special search results that sit above the main organic results in a place known as “position zero”:

In searches where Google thinks visitors will benefit from a short, direct answer, they’ll often choose an excerpt from a high-ranking page to show. Plenty of queries have a featured snippet, so it’s worth trying to win them.

To see which keywords have a featured snippet, head to Keywords Explorer, paste your list of keywords, and hit the SERP features toggle to show only those keywords that have a featured snippet in the search results:

You can also use Site Explorer to find opportunities to optimize your existing pages for featured snippets. Paste in your website URL, use the SERP features selector to show only keywords that have a featured snippet in the SERP that your website doesn’t currently rank for:

For this website, we can see 3,034 coffee-related keywords with a featured snippet. Time to get optimizing!

There’s no guaranteed way to win the featured snippet, but it helps to:

  • Match the existing snippet format (commonly paragraph, list, table, or video)
  • Define your topic succinctly in two to three sentences
  • Keep your content objective and fact-based, and avoid first-person language

Learn more about featured snippets (and how to win them) in our full guide: Featured Snippets: A Shortcut to the Top of Google.

Rich results are search results that give searchers extra information about a page, like product ratings or recipe details. Not every type of search is eligible to show rich results, but for those that are, rich results help drive extra clicks to your page.

To be eligible for rich snippets, you need to apply a simple code called schema markup. Learn how in our guide, Schema Markup: What It Is & How to Implement It.

To rank your pages, Google will also take into account a set of “page experience signals.” These include (but are not limited to):

  • Core Web Vitals (CWV) (in other words, whether the page is fast enough and stable).
  • Security (whether the page connects via HTTPS).
  • Mobile-friendliness (Google uses the mobile version of your pages for indexing and ranking).
  • Avoiding intrusive interstitials and dialogs.

These are problems that can be spotted on individual pages but usually need to be solved at the site level. Check out our guides to learn more:

Final thoughts

On-page SEO can often help content climb higher in the search results, but don’t be disheartened if it doesn’t pay off immediately.

Search results change. Information changes. Your experience and opinions change. In some cases, even the intent behind the search can change (“llm” used to refer solely to a legal degree—now, it usually refers to large language models).

If rankings don’t improve, it’s worth trying to update or strengthen your content again. We do this all the time on the Ahrefs blog, and we’ve had good results from updating or even completely rewriting content.

Below, you can see an example—organic traffic multiplied after a simple update:

Article Performance
Data from Ahrefs

The number of websites linking to this post.

This post's estimated monthly organic search traffic.