Skip to the indexed answers
Digital Marketing Index

usdigitalmarketingindex.com SEO

When should internal links point to a specific section through a URL fragment?

When the reader needs one part of a long page and would otherwise have to hunt for it. A fragment is the part of an address after the hash sign, and it tells the browser to scroll to the element with that identifier. A link from a short answer to the exact paragraph that supports it, from a glossary entry to its definition, or from a troubleshooting step to the relevant section of a manual saves the reader a search within the page. A fragment link is the wrong choice when the reader needs the page from its beginning, when the target section may be renamed or moved, or when the section is substantial enough to deserve a page of its own.

Directing users to a precise answer

Use a fragment when all of these hold.

  • The destination page is long and covers several subjects.
  • The link’s sentence refers to one of them.
  • The section makes sense when arrived at directly.
  • The section has a stable identifier.
Situation Link to Why
A sentence mentions permit requirements, covered in one section of a long installation guide The section The reader wants that part
A link recommends the installation guide as a whole The page The reader should start at the top
A FAQ page with thirty questions, and the link refers to one The question Saves scrolling
A section that depends on definitions given earlier on the page The page, or the section with a note Arriving mid-page would confuse
A section long enough to be an article Consider splitting it into its own page A page can be found in search by itself

What a fragment does not do is create a separate page for search engines. Google’s URL guidance says “Google Search generally doesn’t support URL fragments” as a way of identifying different content (Google’s URL structure guidance). A link to a section is a link to the page. The fragment is a convenience for the visitor.

Stable heading IDs

A fragment link works only while the target identifier exists. Markup for a section and a link to it. The address is an example.

The section, on the destination page:

<h2 id="permit-requirements">Permit requirements</h2>
<p>A permit is required before installation in the cases described below.</p>

The full URL with its fragment:

https://www.example.com/guides/water-heater-installation/#permit-requirements

The link, on another page:

<a href="https://www.example.com/guides/water-heater-installation/#permit-requirements">permit requirements for water heater installation</a>

Rules for identifiers:

  • Unique within the page.
  • Lowercase words separated by hyphens, describing the section.
  • Set explicitly, and kept when the heading text is edited. An identifier generated automatically from the heading changes when the heading does, and every link to it silently stops working.
  • Free of numbering that depends on position, such as section-3, which changes when sections are reordered.
  • Kept as an empty anchor at the new location if a section is moved or merged, so old links still land somewhere sensible.

A broken fragment does not produce an error. The page loads at the top, and the reader, who was promised a specific section, has to look for it. Nothing in a standard broken-link report flags it, because the page returns 200.

Accessibility and analytics caveats

Check how the jump behaves.

  • Focus. After following the link, keyboard focus should move to the target, so that a keyboard or screen reader user continues from there.
  • Fixed headers. A sticky header can cover the target heading. A scroll margin on headings prevents that:
h2[id], h3[id] {
  scroll-margin-top: 5rem;
}
  • Orientation. Arriving mid-page, the reader should be able to tell where they are. A visible heading and the page title in the header are enough.
  • Collapsed content. If the target sits inside a closed accordion or tab, the link must open it. A fragment pointing at hidden content appears to do nothing.
  • Content loaded late. If the target is inserted by script after load, the browser may try to scroll before it exists.

Analytics need attention too.

  • The fragment is not sent to the server. Server logs record the page, without the section.
  • Analytics tools record the page view under the page’s address. Whether the fragment is captured depends on the tool’s configuration.
  • Clicks on in-page fragment links do not load a new page, so they are counted only if tracked as events.

If you want to know which sections are being reached, set up event tracking for fragment navigation.

Good anchor examples

The link text should name the section’s subject, and the sentence should show that the reader will land on a part of a page.

  • Weak: “See here”. Better: See the permit requirements for water heater installation.
  • Weak: “Read our guide”. Better: The installation guide’s section on venting a gas water heater explains the clearances.
  • Weak: “Section 4”. Better: How rebates are paid is covered in the rebates guide.
  • Weak: “Click for more”. Better: The glossary defines first-hour rating.

The bold text marks the link. Each names what will be on screen after the jump.

Maintenance checklist for fragment links:

  1. Keep a list of identifiers that other pages link to. Treat them like URLs: do not change them casually.
  2. When editing a long page, search the site for links to its fragments before renaming or removing a section.
  3. Test fragment links with a tool or script that loads each one and checks that an element with that identifier exists on the page. Ordinary link checkers confirm only that the page loads.
  4. When a section becomes its own page, update links to point to the new page, and leave a short pointer at the old location.
  5. Review after redesigns, which can regenerate identifiers.

Decide between a fragment and a new page with one question: would someone search for this section’s subject as a question in its own right? If yes, and the section is long, it may deserve its own URL, where it can carry its own title. If it is one part of a larger answer, a fragment link serves.

Fragment links from other pages are related to, and different from, the list of in-page links at the top of a long article. When that list is worth adding is covered in the guide to when a long informational page benefits from a linked table of contents.

The criterion: link to a section when the reader wants that part and the identifier will stay put. Otherwise link to the page.

Link trail

Reader comments on this answer

Add your comment to this answer

Your email address will not be published. Required fields are marked *