Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links are not crawlable with acceptable URL #11818

Closed
JPPhoto opened this issue Dec 11, 2020 · 8 comments · Fixed by #13105
Closed

Links are not crawlable with acceptable URL #11818

JPPhoto opened this issue Dec 11, 2020 · 8 comments · Fixed by #13105

Comments

@JPPhoto
Copy link

JPPhoto commented Dec 11, 2020

Provide the steps to reproduce

  1. Run LH on https://www.cupcakeproject.com/best-vanilla-cupcake-recipe/

What is the current behavior?

I see "Links are not crawlable" for this element:

<a href="https://www.pinterest.com/pin/create/bookmarklet/?url=https%3A%2F%2Fwww.cu…" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,men…" data-recipe="21315" style="color: #333333;" class="wprm-recipe-pin wprm-recipe-link wprm-block-text-normal" target="_blank" rel="nofollow noopener noopener noreferrer">

What is the expected behavior?

Since the full link is crawlable, I wouldn't expect to see this error. The link has urlencoded parts, so perhaps that's triggering an issue; opening the URL in a browser shows the expected page.

Environment Information

  • Affected Channels: All
  • Lighthouse version: 6.3.0
  • Chrome version: 87.0.4280.88
  • Node.js version:
  • Operating System: Windows 10 20H2

Related issues

@patrickhulce
Copy link
Collaborator

Thanks for filing @JPPhoto!

I'm really surprised this case of a valid href + onclick=window.open wasn't explicitly covered in #10590 or anywhere in our tests 😐 Conceptually I think this should be fine for the same reasons as #11443 (comment).

cc @AVGP in case this should still be considered failing for a reason I'm not aware of :)

@JPPhoto
Copy link
Author

JPPhoto commented Dec 11, 2020

@patrickhulce I should add that the URI is valid, whether or not the onclick JS is invoked. I get that Lighthouse would report an error iff the onclick handler tried to deceive the user; perhaps this is rather hard to detect and it's easier to flag instances as errors? Having not looked at the code, I don't know what's going on under the hood.

@connorjclark
Copy link
Collaborator

connorjclark commented Apr 20, 2021

1- we'd have to click every link and make sure the accompanying network request actually matches the provided href value...

2- we'd have to make sure that search/crawlers even try to resolve links with an onclick... or just ignore onclick and use href ? cc @AVGP any thoughts here?

ideally we could just check for href and ignore all else ... but only if crawlers actually work like that :)

@AVGP
Copy link
Collaborator

AVGP commented May 5, 2021

So as far as Google Search is concerned, look at the href and that's it. Googlebot only has an issue with hrefs like javascript:doStuff('home') or # as none of these are crawlable URLs (well the empty fragment is, but it's just the current page anyway)

@patrickhulce
Copy link
Collaborator

thanks @AVGP! We'll mark a valid href + onclick handler as passing then 👍

@svkrclg
Copy link
Contributor

svkrclg commented Aug 1, 2021

I can pick this up @patrickhulce. Upon looking at the codebase, this is where the anchor is getting marked as failed.
Few doubts here:

  • why have we marked window.open as failed anchor tag?
  • How can we verify onclick handler as valid?

@patrickhulce
Copy link
Collaborator

why have we marked window.open as failed anchor tag?

The purpose of this audit is to flag links that are not crawlable. <a onclick="window.open('http://example.com')"> is not crawlable.

How can we verify onclick handler as valid?

We aren't. This change is about considering an anchor valid if it has a valid href, regardless of onclick behavior.

@paulirish
Copy link
Member

fixed by #13105. shipped in LH 8.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants