All Projects → itbdw → server-render-javascript

itbdw / server-render-javascript

Licence: MIT license
Prerender your javascript web page for better seo with PhantomJS. ⚠️ no es6 supported.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to server-render-javascript

parcel-plugin-prerender
No description or website provided.
Stars: ✭ 42 (+250%)
Mutual labels:  seo, prerender
react-seo-friendly-spa-template
React PWA/SPA template initially scaffolded with CRA (Create React App) and configured for SEO. Makes use of prerendering and other techniques/packages in order to achieve a perfect "Lighthouse Score".
Stars: ✭ 24 (+100%)
Mutual labels:  seo, prerender
Chrome Prerender
Render JavaScript-rendered page as HTML/PDF/mhtml/png/jpeg using Headless Chrome
Stars: ✭ 161 (+1241.67%)
Mutual labels:  prerender, server-rendering
Prep
Pre-renders your web app (React, Vue, Angular, ...) into static HTML based on your specified routes enabling SEO for single page applications.
Stars: ✭ 371 (+2991.67%)
Mutual labels:  seo, prerender
Prerender Spa Plugin
Prerenders static HTML in a single-page application.
Stars: ✭ 7,018 (+58383.33%)
Mutual labels:  seo, prerender
Vue Seo Prerender
Vue.js Tutorial: A Prerendered, SEO-Friendly Example
Stars: ✭ 139 (+1058.33%)
Mutual labels:  seo, prerender
koa-seo
koa SEO middleware
Stars: ✭ 36 (+200%)
Mutual labels:  seo, server-rendering
React Snap
👻 Zero-configuration framework-agnostic static prerendering for SPAs
Stars: ✭ 4,565 (+37941.67%)
Mutual labels:  seo, prerender
Usus
Webpage pre-rendering service. ⚡️
Stars: ✭ 804 (+6600%)
Mutual labels:  seo, prerender
Prerender Java
java framework for prerender
Stars: ✭ 115 (+858.33%)
Mutual labels:  seo, prerender
vue-seo-friendly-spa-template
Vue.js PWA/SPA template initially scaffolded with vue-cli and configured for SEO. Makes use of prerendering and other techniques/packages in order to achieve a perfect "Lighthouse Score".
Stars: ✭ 41 (+241.67%)
Mutual labels:  seo, prerender
react-webpack2-skeleton
Get started with React with Webpack2, React-Router, Redux, Code Splitting and Server Rendering
Stars: ✭ 59 (+391.67%)
Mutual labels:  server-rendering
NextBook
NextBook is quick and easy way to build technical books or documentation with markdown that run blazingly fast.
Stars: ✭ 153 (+1175%)
Mutual labels:  seo
text-generator
Golang text generator for generate SEO texts
Stars: ✭ 18 (+50%)
Mutual labels:  seo
classicpress-seo
Classic SEO is the first SEO plugin built specifically to work with ClassicPress. A fork of Rank Math, the plugin contains many essential SEO tools to help optimize your website.
Stars: ✭ 18 (+50%)
Mutual labels:  seo
flyyer-wp
👉 Visit the wiki: https://github.com/useflyyer/flyyer-wp/wiki | Generate social share images with web technologies
Stars: ✭ 13 (+8.33%)
Mutual labels:  seo
awesome-search-engine-optimization
A curated list of backlink, social signal opportunities, and link building strategies and tactics to help improve search engine results and ranking.
Stars: ✭ 82 (+583.33%)
Mutual labels:  seo
web-onefx-boilerplate
Full-stack React Framework for building web and backend
Stars: ✭ 34 (+183.33%)
Mutual labels:  server-rendering
example-app
Example app showcasing fulls1z3's Angular libraries
Stars: ✭ 27 (+125%)
Mutual labels:  seo
universal-react-starter-kit
Universal React Starter Kit is an universal web application framework using koa, react, redux and webpack.
Stars: ✭ 13 (+8.33%)
Mutual labels:  seo

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

WARNING

This is a thing waste of your time!

警告

纯属浪费时间,不要尝试。

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

server-render-javascript

Prerender your javascript web page for better seo with PhantomJS.

Dependency

Must

PhantomJS, a server headless browser.

NodeJS, serve phantomjs.

Suggested

pm2, start the server and much more.

Install

Suppose you are using a Ubuntu Server and nginx as web server.

  1. NodeJS
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

sudo apt-get install -y nodejs

  1. PhantomJS

Go http://phantomjs.org/download.html and download a latest version, extract it, cd the dir, and mv bin/phantomjs /usr/bin, that is all!

  1. Install and Run

Download this code to your server, say /var/server/spider, the directory structure looks like below

/var/server/spider/
                    craw.js
                    package.json
                    spider.js

Any thing within craw.js and spider.js can be modified for your actual need.

cd /var/server/spider
npm install

PORT=3000 pm2 -f start spider.js

after started, you can use pm2 logs to monitor logs, pm2 list to display services and much more.

  1. Proxy Request

I suppose you use nginx as web server and run the nodejs and nginx at same server.

upstream spider {
    server localhost:3000;
}

server {
    ...
    
    
    set $is_spider 0;
    set $is_server_render 0;

    if ($http_user_agent ~ Baiduspider) {
       set $is_spider 1;
    }

    if ($http_user_agent ~ Googlebot) {
       set $is_spider 1;
    }

    if ($http_user_agent ~ ServerRender) {
       set $is_server_render 1;
    }

    set $is_spider_is_render $is_spider$is_server_render;

    location / {
        ...        
    
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        if ($is_spider_is_render = 10) {
             proxy_pass http://spider;
        }

        ...
    }
    ...
}

After changing nginx config, don't forget reload the nginx.

You can make a request and check your nginx access log if anything works great.

curl -A 'fake Googlebot by server-render-javascript' http://yourwebsite.com/abc

You should get two line in nginx access log, one is your request with user-agent fake Googlebot by server-render-javascript and one made by your upstream server with user-agent ServerRenderJavascript, if you have not change the default user-agent at craw.js.

Caution

  • Watch out the timeout in craw.js

What and how it works

Your website is rendered with javascript. But search engine (like Baidu, Sogou, 360) does not like the page, and even can not understand javascript content totally.

So, why don't we run a browser on the server side. When spider like Googlebot comes to your website, proxy the request to a upstream server, why not nodejs server, and the upstream server deal the request with a headless browser and make a new request just like the we human visit website by Safari or Chrome and return the rendered content back.

The workflow looks like this

GoogleBot => Web Server => NodeJS Server => Make A Request Again With Server Browser => Get Web Content And Return

In fact, Chrome also support headless browse after version 59. But compared with PhantomJS for now, PhantomJS is better and easy to use. you can find a chrome version at https://github.com/itbdw/server-render-javascript-chrome

Thanks

Prerender For SEO

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].