大网数据广告活动
网站运营与故障问答

Does using onclick to redirect parameters impact SEO?

· 52CE 我爱测

For SEO, I need to have my link https://www.example.com/ on a third party website. However, I also need this website to pass parameters to my site. If the third party website used the below structure would it pass a backlink to m…

问题原文

原帖链接 · user1609391 · CC BY-SA 4.0

For SEO, I need to have my link https://www.example.com/ on a third party website. However, I also need this website to pass parameters to my site.

If the third party website used the below structure would it pass a backlink to my main URL https://www.example.com/ or would it pass a backlink to https://www.example.com/?xyz=55

Would this be seen as legit from an SEO perspective or pushing it? Is there a better way to accomplish this from an SEO perspective?

<script>
   var val = 55;
</script>

Link to <a href="https://www.example.com/" onclick="location.href=this.href+'?xyz='+val;return false;">My Site</a>

社区高分解答

原帖链接 · Muhammad Dyas Yaskur · CC BY-SA 4.0

Based on Links Crawable Guidelines, the link will be crawled as https://www.example.com/, because Google can not follow link from onclick attributes.

Google search central says:

Google can follow links only if they are an <a> tag with an href attribute. Links that use other formats won't be followed by Google's crawlers. Google cannot follow <a> links without an href tag or other tags that perform a links because of script events. Here are examples of links that Google can and can't follow:

  • Can follow:
    • <a href="https://example.com">
    • <a href="/relative/path/file">
  • Can't follow:
    • <a routerLink="some/path">
    • <span href="https://example.com">
    • <a onclick="goto('https://example.com')">

I just saw the test that @Trebor mentioned in a comment which says The onclicks links were fully crawled and followed, but that test was created in 2015, and the official guidelines was first captured at 2020-11-11 and the last updated at 2021-08-26, so I prefer to believe in official announcements than the test. Because I think the test is outdated, I need the test that created at least this year to prove it.

I see in your comment says:

I'm thinking of blocking the parameter pages with robots.txt or in webmaster tools to prevent duplicate content and put the focus on https://www.example.com

Based on Duplicate URLs guideline, don't block pages using robots.txt, just use rel=canonical <link> tag , rel=canonical HTTP header, Sitemap, 301 redirect, or AMP variant as described at official Google guideline.

General guidelines For all canonicalization(duplicate URLs signal) methods, follow these general guidelines:

  • Don't use the robots.txt file for canonicalization purposes.

  • Don't use the URL removal tool for canonicalization. It removes all versions of a URL from Search.

  • Don't specify different URLs as canonical for the same page using the same or different canonicalization techniques (for example, don't specify one URL in a sitemap but a different URL for that same page using rel="canonical").

  • Don't use noindex as a means to prevent selection of a canonical page. This directive is intended to exclude the page from the index, not to manage the choice of a canonical page.

  • Specify a canonical page when using hreflang tags. Specify a canonical page in same language, or the best possible substitute language if a canonical doesn't exist for the same language.

  • Link to the canonical URL rather than a duplicate URL, when linking within your site. Linking consistently to the URL that you consider to be canonical helps Google understand your preference.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2021-09-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。