TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Understand the JavaScript SEO basics

228 点作者 jaequery将近 6 年前

10 条评论

sharkweek将近 6 年前
SEO consultant here (yeah, yeah).<p>Please, still in 2019, be careful with JavaScript unless you&#x27;re willing to deal with a lot of uncertainty.<p>Google routinely says how things are <i>supposed</i> to work, but there are plenty of examples where their crawlers act inconsistent to public statements. To be clear, probably not Googlebot&#x27;s fault though; we as a species do a lot of weird things when building websites.<p>Just finished a big project with a client who had a client-side render of their react app for the customer facing website. Googlebot was VERY sporadic with how they were indexing certain parts of the site, and in general, the site lost out to inferior sites in more competitive SERPs. Server side render fixed a lot of this and rankings&#x2F;traffic jumped.<p>It&#x27;s also worth noting that the Bing&#x2F;Yahoo crawlers (still a notable chunk of web traffic!) can&#x27;t crawl JS. You can ignore this chunk of market share if you want but someone is going to happily take it.<p>As a general rule, my advice is always this: Make it as easy as possible for bots to crawl and index your site&#x27;s content. The more hoops the crawler is jumping through, the worse your site will perform in search engines.
评论 #20483179 未加载
评论 #20482691 未加载
评论 #20485078 未加载
rayshan将近 6 年前
I echo what others like @sharkweek are saying - Google has been saying that they index JavaScript for quite a while now. At I&#x2F;O 2019 they said the crawler should be on the latest Chromium codebase that supports all modern JavaScript features. I built some test cases [0] to see if this is true, and just couldn&#x27;t get Google to index content inserted via JavaScript. For example, scroll down to the Popover button test case.<p>Maybe I&#x27;m doing something wrong? Open to feedback. Opensourced code is here [1].<p>[0]<a href="https:&#x2F;&#x2F;shan.io&#x2F;will-it-index&#x2F;" rel="nofollow">https:&#x2F;&#x2F;shan.io&#x2F;will-it-index&#x2F;</a><p>[1]<a href="https:&#x2F;&#x2F;github.com&#x2F;rayshan&#x2F;rayshan.github.io&#x2F;tree&#x2F;master&#x2F;will-it-index" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rayshan&#x2F;rayshan.github.io&#x2F;tree&#x2F;master&#x2F;wil...</a>
评论 #20483331 未加载
davnicwil将近 6 年前
For those here to find out how relevant server rendering is for SPAs in light of this, I think the answer is still very much &#x27;better if you do&#x27;.<p>Some relevant excerpts from the article (emphasis mine):<p>&gt; Keep in mind that server-side or pre-rendering is still a great idea because <i>it makes your website faster</i> for users <i>and crawlers</i>, and not all bots can run JavaScript.<p>&gt; <i>Once Googlebot&#x27;s resources allow</i>, a headless Chromium renders the page and executes the JavaScript.<p>So, there are still no specifics on what extra delays might be involved, but this seems to suggest what I&#x27;ve heard about JS-rendered content still taking much longer than static content to update in the index (i.e. days to weeks) might indeed be the case.<p>I.e. seems they are implying that while this <i>works</i>, static content is still preferred by them and takes priority.
mattmanser将近 6 年前
This feels like such a smoke and mirrors thing. This gem:<p><i>Write compatible code<p>Browsers offer many APIs and JavaScript is a quickly-evolving language. Googlebot has some limitations regarding which APIs and JavaScript features it supports. To make sure your code is compatible with Googlebot, follow our guidelines for troubleshooting JavaScript problems.</i><p>Leads to this page:<p><a href="https:&#x2F;&#x2F;developers.google.com&#x2F;search&#x2F;docs&#x2F;guides&#x2F;fix-search-javascript" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;search&#x2F;docs&#x2F;guides&#x2F;fix-search-...</a><p>Which says absolutely nothing. It details nothing about what is supported.<p>Utterly useless. No version of HTML running, no info about what gets run, no actual technical details at all.
tuukkah将近 6 年前
Perhaps the biggest gotcha was that Googlebot was running Chromium that was years old and required polyfills that you wouldn&#x27;t otherwise include anymore. Since May they run a recent Chromium though: &quot;The new evergreen Googlebot&quot; <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=20482235" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=20482235</a>
tobr将近 6 年前
Search Engine Optimization? More like Googlebot Optimization, I think.
评论 #20481650 未加载
评论 #20483191 未加载
ashton314将近 6 年前
A little off-topic, but one of the most exciting things in my mind about Phoenix LiveView [1] is that you can get some dynamic web applications and not have to navigate this JS-rendering minefield. When a LiveView page is request, the server sends over the <i>full page</i> as just static HTML. The JS half of LiveView then upgrades to a websocket connection, and your page becomes dynamic.<p>Not a good fit for everything, but it&#x27;s great if you want to add some fancy form validation to, say, your landing page. You can render whatever you want with LiveView, get your fancy dynamic stuff, without having to worry about making your page more indexable.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;phoenixframework&#x2F;phoenix_live_view" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;phoenixframework&#x2F;phoenix_live_view</a>
评论 #20500743 未加载
arrty88将近 6 年前
I use middleware on my SPA’s static server that sends bots a lite SSR version of the page that gets SEO’d up pretty well. Best of both worlds
评论 #20484647 未加载
rhacker将近 6 年前
Is this the first confirmation from Google that they render JS&#x2F;SPAs? I&#x27;ve heard rumors before...
评论 #20480528 未加载
评论 #20483082 未加载
评论 #20480912 未加载
kazinator将近 6 年前
A good search engine shouldn&#x27;t process JS at all, and index only the content that is reachable via links pulled from HTML (which may, of course, be dynamic).<p>The processing of JS explains a lot of the sheer garbage that is in the Google results.<p>I think they do it because it ties into their business model. JS is needed to unearth the kind of crap that a certain segment of the user base is looking for. That certain segment is worth catering to because it consists of users who are likely to click on ads.<p>Otherwise, nobody in their right mind would integrate JS into a crawler. &quot;I&#x27;m going to write a program that automatically finds random source code, much of it malicious, and runs it!&quot; Come on; without a business agenda justifying it, it&#x27;s a complete non-starter.
评论 #20481506 未加载
评论 #20481867 未加载
评论 #20481518 未加载
评论 #20481965 未加载
评论 #20482351 未加载