-1

I want to disallow pages that develop after someone comments on my post. For example, recently I got a comment (number 12) on my post page and a new page was formed with URL:

https://example.com/post/#comment-12

Now if another person comments (number 13) on my post then I am expecting a page URL like:

https://example.com/post/#comment-13

So my question is what should I put in my robots.txt disallow path to avoid google index my post pages that are developing after comments.

Currently, the path I have given in my robots.txt file to restrain google from indexing my comment files with different number is as follow:

Disallow: /*#comment-

By this directive, I mean google shouldn't index any url related to my website that includes #comment-

I am not sure whether I am right or not please assist me in disallowing my comments.

Thanks. Allah Bless You.

1 Answers1

1

There is only one web page here. The hash and text beyond it are a named anchor, which points to a specific location on that page. If you click one it will load the page /post/ and then scroll down to comment 12 or 13 or whichever one you clicked.

Search engines will just load the whole page. They are smart enough to not try to load a named anchor as if it were a separate page. (However, note that there are a couple of old web frameworks that abused the anchor to create actual separate "pages" in a single-page app. This approach has been largely abandoned due to the variety of problems it caused, but your site doesn't appear to be one of these.)

You don't need to do anything in robots.txt.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972