5

So I'm probably overthinking this, as I do with everything. But I'm just curious to what others think.

In general, naming a HTML anchor link should be short and related, but if you have a table of content, what would then be best practice (from both seo as technical point of view):

  1. matching the exact heading
  2. leave out words with little meaning (such as 'in', 'and')

For example: if your table of content looks like this

  1. an example about the anchor links
  2. creating anchor links on your page

So you would make an anchor link for '1. an example about the anchor links'. Should it be #example-anchor-links or the exact phrase #an-example-about-the-achor-links

On one hand, keeping it short as possible seems like good practise, but on the other hand it might be better to make it an exact match.

Just curious how other people think about this, because I sometimes see the first example and sometimes the second. It might not make huge differences, but since I'm just starting implementing it, I'd rather have the best way right now and be consistent with that for the future.

2
  • 1
    Why not just #example and #creating? The context of the page is already all about anchor links, is there a need to repeat that information in the URL? Jan 18, 2022 at 14:04
  • It's really not about the content in the example. It's about the best way to link to the headings when making a table content: Using the exact phrases or leaving out the words without meaning. Maybe the example wasn't the best one. But you'd use the headings to link to, so you can't make seperate ones (hopefully I explain it a bit clearly)
    – noddie
    Jan 18, 2022 at 17:51

2 Answers 2

2

we keep all of the anchors in our tables short and related to the sections they're linking to. This could avoid accidental typos and saves a fraction of a second when creating these anchors. Additionally, using exact match anchors won't really have an impact on your SEO performance.

0

The text after the # is also called a fragment identifier. I don't think it has any impact on SEO, so you can use small identifiers.

Firstly, it's not sent to the server, the browser handles it.

Anchor #SomewhereInTheDocument is an anchor to another part of the resource itself. An anchor represents a sort of "bookmark" inside the resource, giving the browser the directions to show the content located at that "bookmarked" spot. On an HTML document, for example, the browser will scroll to the point where the anchor is defined; on a video or audio document, the browser will try to go to the time the anchor represents. It is worth noting that the part after the #, also known as the fragment identifier, is never sent to the server with the request.

From developer.mozilla


Secondly, it's not normally indexed, it is ignored by search engines.

  1. Googlebot Ignores Fragments By Default

From Things You Should Know About Fragment URLs

The response from Mueller was blunt:

If we remove URL fragments since they are processed on the client side and are not relevant when the information is obtained from your server.

From How to handle search engines: Fragment Identifier URLs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.