Where keywords go in your HTML and why search engines look there

Search engines read the HTML code behind your website to understand what your pages are about. Keywords — the words people type into Google when looking for what you offer — need to appear in specific places in that code so search engines find them. The three places that matter most are the page title, the meta description, and the body text itself.

You do not need to stuff keywords everywhere. Search engines now penalize pages that repeat the same word too many times. Instead, you are aiming for keywords that match what your page actually discusses, placed naturally in the spots where search engines expect to find them.

If you use a website builder like Wix, Squarespace, or WordPress, you have a form that fills in these HTML fields for you — you do not write the code directly. If you edit HTML by hand, you will add these fields yourself. Either way, the same three locations do the work.

Key Takeaways

  • The page title (the text in the <title> tag) is the single most important place for your main keyword, and it appears in browser tabs and search results.
  • The meta description is a 150-character summary that appears under your page title in search results and should include your keyword naturally.
  • Your actual page content — the words visitors read — must contain your keywords in headings and body text, or search engines will not rank you for them.
  • Keyword placement matters more than keyword count; one natural mention in the title and a few in the body text outperforms keyword repetition.
  • Website builders have fields labeled "SEO Title," "Meta Description," or "Page Title" that write the HTML for you without needing to touch code.

The page title tag and how to write it for search engines

The page title is the text that appears in your browser tab and as the blue clickable link in search results. In HTML, it lives inside a <title> tag in the head section of your page. This is the single most important place to put your main keyword.

Write your page title to include your keyword at or near the beginning, but make it readable to a human first. A title like "Best Coffee Shops in Portland" works better than "Coffee Shops Portland Coffee Shops Best." Search engines prefer titles between 50 and 60 characters because longer titles get cut off in search results.

If you use WordPress, open the page editor and look for a box labeled "SEO Title" or "Focus Keyword" — usually provided by a plugin like Yoast SEO or Rank Math. Type your keyword-rich title there. If you edit HTML directly, the code looks like this: <title>Best Coffee Shops in Portland | Local Guide</title>. In Wix or Squarespace, find the page settings or SEO panel and fill in the "Page Title" field.

The meta description and why it matters for clicks

The meta description is a 150-character summary of your page that appears directly under the title in search results. Search engines do not use it to rank your page, but people use it to decide whether to click. Including your keyword naturally in the meta description helps searchers see that your page matches what they are looking for.

Write your meta description as a complete sentence or two that describes what the page contains. Include your keyword once, naturally. A good example: "Find the best coffee shops in Portland with our guide to local roasters, seating, and WiFi. Updated monthly." A bad example: "Coffee shops Portland coffee shops best Portland coffee." The first one gets clicks; the second one looks like spam.

In WordPress, the meta description field sits directly below the SEO title field in your editor. In Wix, look for "SEO Description" in the page settings. In Squarespace, it is under "Page Settings" and labeled "Meta Description." Keep it under 160 characters so it does not get cut off on mobile devices.

Keywords in your page headings and body text

After the title and description, your actual page content is where keywords do their real work. Search engines read your headings (the <h1>, <h2>, and <h3> tags) and your body paragraphs to understand what your page is really about. If your keyword never appears in the content itself, search engines will not rank you for it, no matter how many times you put it in the title.

Use your main keyword in at least one heading on the page — ideally the <h1>, which is usually your page headline. Then use it naturally in the first paragraph and once or twice more throughout the body. You are aiming for a keyword density of roughly 1 to 2 percent — meaning if your page is 1,000 words, your main keyword appears 10 to 20 times. More than that looks unnatural and search engines will penalize you.

Related keywords matter too. If your main keyword is "coffee shops in Portland," also use variations like "Portland cafes," "best local coffee," and "Portland roasters" throughout your content. This tells search engines your page covers the topic thoroughly and helps you rank for multiple related searches.

How to find keywords worth putting in your HTML

Before you add keywords to your HTML, you need to know which keywords are actually worth targeting. A keyword is worth targeting if people search for it and your page can genuinely answer their question. You can research keywords using free tools like Google Search Console, which shows you what searches already bring people to your site, or Google Trends, which shows you search volume over time.

Start with the keywords you think your page should rank for — the ones your customers use when looking for your product or service. Then search for those keywords in Google and look at the top results. If those pages are similar to yours, the keyword is worth targeting. If the top results are from huge companies or completely different types of pages, that keyword may be too competitive or not relevant to what you offer.

Long-tail keywords — phrases with three or more words — are usually easier to rank for than single words. "Best coffee shops in Portland Oregon" is easier to rank for than just "coffee." Longer phrases also match what people actually type into search boxes, so they bring more may have access to visitors to your site.

Common mistakes that hurt your keyword placement

The most common mistake is putting keywords in your HTML but not in your actual page content. Your title might say "Best Coffee Shops in Portland," but if the page itself never mentions Portland or coffee shops, search engines will not rank you for those terms. The HTML fields and the page content have to match.

The second mistake is keyword stuffing — repeating your keyword so many times that the page reads unnaturally. Search engines now detect this and rank you lower, not higher. Write for humans first. If your keyword does not fit naturally into a sentence, leave it out and use a related word instead.

The third mistake is using the same keyword for every page on your site. Each page should target a different keyword or keyword phrase. If you have ten pages all optimized for "coffee shops," search engines will not know which one to rank, and they may rank none of them. Instead, optimize one page for "best coffee shops," another for "coffee shops with WiFi," and another for "coffee shops near downtown."

How different website builders handle keyword fields

Website BuilderWhere to Find Keyword FieldsWhat the Fields Are Called
WordPressPage editor, usually in a sidebar or below the contentSEO Title, Meta Description, Focus Keyword (if using Yoast or Rank Math)
WixPage settings, click the gear iconSEO Title, SEO Description
SquarespacePage settings, click the gear iconPage Title, Meta Description
ShopifyProduct or page editor, scroll to the bottomPage Title, Meta Description
Hand-coded HTMLThe <head> section of your HTML file<title> tag, <meta name="description"> tag

Frequently Asked Questions

Do I need to add keywords to every page on my site?

Yes, but each page should target a different keyword or keyword phrase. Your homepage might target "coffee shop," a product page might target "espresso machine," and a blog post might target "how to brew cold brew." This way, search engines know what each page is about and can rank you for multiple searches.

How many keywords should I put in my page title?

One main keyword is ideal. You can include a secondary keyword if it fits naturally — for example, "Best Coffee Shops in Portland | Local Guide" targets both "coffee shops" and "Portland." But do not try to cram five keywords into a 60-character title. Search engines and humans both prefer titles that read naturally.

Will adding keywords to my HTML may provide I rank in search results?

No. Keywords in your HTML are necessary but not sufficient. Search engines also look at how many other sites link to you, how fast your site loads, whether it works on mobile phones, and how long visitors stay on your page. Keywords are one piece of a larger picture.

What if my keyword is too competitive and I cannot rank for it?

Target a longer, more specific keyword instead. If "coffee" is too competitive, try "specialty coffee roasters in Portland" or "third-wave coffee shops near Pearl District." These longer phrases have less competition and bring visitors who are looking for exactly what you offer.

Can I change my keywords after I publish a page?

Yes. You can edit your page title, meta description, and content at any time. Search engines will re-read your page and update their index within days or weeks. If you are changing keywords because your old ones were not working, give the new keywords at least a month to show results before changing them again.