You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Google, Facebook, Twitter, Yahoo, and Bing are constantly trying to view your website... but they don't execute javascript. That's why we built Prerender. Prerender is perfect for AngularJS SEO, BackboneJS SEO, EmberJS SEO, and any other javascript framework.
4
+
Google, Facebook, Twitter, and Bing are constantly trying to view your website... but Google is the only crawler that executes a meaningful amount of JavaScript and Google even admits that they can execute JavaScript weeks after actually crawling. Prerender allows you to serve the full HTML of your website back to Google and other crawlers so that they don't have to execute any JavaScript. [Google recommends using Prerender.io](https://developers.google.com/search/docs/guides/dynamic-rendering) to prevent indexation issues on sites with large amounts of JavaScript.
5
5
6
-
This middleware intercepts requests to your Rails website from crawlers, and then makes a call to the (external) Prerender Service to get the static HTML instead of the javascript for that page.
6
+
Prerender is perfect for Angular SEO, React SEO, Vue SEO, and any other JavaScript framework.
7
7
8
-
Prerender adheres to google's `_escaped_fragment_` proposal, which we recommend you use. It's easy:
9
-
- Just add <meta name="fragment" content="!"> to the <head> of all of your pages
10
-
- If you use hash urls (#), change them to the hash-bang (#!)
11
-
- That's it! Perfect SEO on javascript pages.
8
+
This middleware intercepts requests to your Node.js website from crawlers, and then makes a call to the (external) Prerender Service to get the static HTML instead of the JavaScript for that page. That HTML is then returned to the crawler.
12
9
13
10
`Note` Make sure you have more than one webserver thread/process running because the prerender service will make a request to your server to render the HTML.
14
11
@@ -22,7 +19,7 @@ And in `config/environment/production.rb`, add this line:
22
19
config.middleware.use Rack::Prerender
23
20
```
24
21
25
-
or if you have an account on [prerender.io](http://prerender.io) and want to use your token:
22
+
or if you have an account on [prerender.io](https://prerender.io/) and want to use your token:
@@ -32,21 +29,15 @@ or if you have an account on [prerender.io](http://prerender.io) and want to use
32
29
33
30
## Testing
34
31
35
-
When testing make sure you're not using a single threaded application server like default WEBrick one, use Puma or Unicorn.
32
+
When testing make sure you're not using a single threaded application server like default WEBrick one, use Puma or Unicorn to prevent a deadlock when the Prerender Service needs to render your HTML on the fly.
36
33
37
-
If your URLs use a hash-bang:
34
+
The best way to test the prerendered page is to [set the User Agent of your browser to Googlebot's user agent](https://developers.google.com/web/tools/chrome-devtools/device-mode/override-user-agent) and visit your URL directly. If you View Source on that URL, you should see the static HTML version of the page with the `<script>` tags removed from the page. If you still see `<script>` tags then that means the middleware isn't set up properly yet.
38
35
39
-
If you want to see `http://localhost:5000/#!/profiles/1234`
40
-
Then go to `http://localhost:5000/?_escaped_fragment_=/profiles/1234`
41
-
42
-
If your URLs use push-state:
43
-
44
-
If you want to see `http://localhost:5000/profiles/1234`
45
-
Then go to `http://localhost:5000/profiles/1234?_escaped_fragment_=`
36
+
`Note` If you're testing locally, you'll need to run the [prerender server](https://github.com/prerender/prerender) locally so that it has access to your server.
46
37
47
38
## How it works
48
39
1. The middleware checks to make sure we should show a prerendered page
49
-
1. The middleware checks if the request is from a crawler (`_escaped_fragment_` or agent string)
40
+
1. The middleware checks if the request is from a crawler by checking the user agent string against a default list of crawler user agents
50
41
2. The middleware checks to make sure we aren't requesting a resource (js, css, etc...)
51
42
3. (optional) The middleware checks to make sure the url is in the whitelist
52
43
4. (optional) The middleware checks to make sure the url isn't in the blacklist
We host a Prerender server at [prerender.io](http://prerender.io) so that you can work on more important things, but if you've deployed the prerender service on your own... set the `PRERENDER_SERVICE_URL` environment variable so that this middleware points there instead. Otherwise, it will default to the service already deployed by [prerender.io](http://prerender.io).
131
+
We host a Prerender server at [prerender.io](https://prerender.io/) so that you can work on more important things, but if you've deployed the prerender service on your own... set the `PRERENDER_SERVICE_URL` environment variable so that this middleware points there instead. Otherwise, it will default to the service already deployed by [prerender.io](https://prerender.io/).
0 commit comments