Martin Splitt of Google, in a rare case about talking specifically about Google rankings, said that he has confirmed that while Google can discover links within commented out HTML code, those links do not get used for ranking purposes in Google.
Here what Martin said on Twitter "so, after a bit of digging and pending a bit of testing (I'm fairly convinced on the results, but better safe than sorry) I think we're discovering (!) links inside comments but don't pass 'em on to ranking. So it's working-as-intended there."
This comes after Jamie Alberico asked about it:
Let me say: It shouldn't 🙃
— Martin Splitt @ home 🏡🇨🇭 (@g33konaut) October 8, 2020
Some folks questioned his original response so he promised to look into it:
I wouldn't be surprised if the extraction just ignores the fact that a link element is a child to a comment node. I didn't look to check yet, I just wouldn't be surprised.
— Martin Splitt @ home 🏡🇨🇭 (@g33konaut) October 8, 2020
And then he said, nope, links in commented out HTML does not pass any ranking weight.
So, after a bit of digging and pending a bit of testing (I'm fairly convinced on the results, but better safe than sorry) I think we're discovering (!) links inside comments but don't pass 'em on to ranking. So it's working-as-intended there.
— Martin Splitt @ home 🏡🇨🇭 (@g33konaut) October 21, 2020
To be clear, HTML comments are not like blog comments, it is when coders mark up their code to add comments about why they coded something. It is like a way to keep notes and reminders about why code was done a specific way. HTML comments are not displayed in the browser, but they can help document your HTML source code.
They can show up in the HTML as but they do not show on the web site.
Forum discussion at Twitter.
Update: One more form example:
Ah, I see! Thanks for the follow-up :)
— Martin Splitt @ home 🏡🇨🇭 (@g33konaut) October 22, 2020
I've looked at the HTML parser and I don't know if those links would be picked up, tbh. Either those text nodes are skipped or they might be picked up, too... would need to dig more for that.