Vahid Najafi
Vahid Najafi

Reputation: 5243

Can social networks run JavaScript when indexing?

For a few years, Google crawlers can run JavaScript in SPA websites in order to index the content of the website. But social networks (like Twitter, Facebook, et cetera) do not.

Incidentally I saw this website that uses AngularJS (version 1.x, so there is no Angular universal). It uses routing and all meta tags are like this (you can see the others in the page source):

<title>{{$meta.title}}</title>

But social networks are able to render them (tested in Twitter and Telegram messenger).

Any idea how this is possible? Do social networks run JavaScript?

Upvotes: 2

Views: 86

Answers (1)

Tomasz Kajtoch
Tomasz Kajtoch

Reputation: 642

Unfortunately, social networks still don't run javascript in SPA pages.

You can make a simple test to simulate Facebook's crawler and check what the site you linked does under the hood. It looks like the page returns another response when the User-Agent connects with one of the social crawlers (e.g. facebookexternalhit/1.1 for Facebook).

You can check it by yourself by running the following command in your terminal:

curl -A "facebookexternalhit/1.1" <page address>

The page you linked returns a result that looks like it renders on the server side:

Response for Chrome User-Agent:

[...]
<meta name="description" content="{{$meta.description}}">
[...]

Response for Facebook Crawler User-Agent:

[...]
<meta name="description" content="Login4 is a beautiful Login component for your Ionic app. This template contains Intro, Walkthrough, Login and Sign up screens.">
[...]

Even if Angular 1.x does not support server-side rendering there is another method - render the page using a real browser, save the HTML output and make a "cached" version for the crawlers. If the HTTP server recognizes crawler's User-Agent, it sends as a response a file from another directory.

Upvotes: 3

Related Questions