Skip to content

Commit

Permalink
改進prerender的文件說明
Browse files Browse the repository at this point in the history
感謝frozenmouse協助修改文件

Co-Authored-By: frozenmouse <frozenmouse@gmail.com>
  • Loading branch information
SoftwareSing and frozenmouse committed Mar 8, 2019
1 parent c7c7ff2 commit 33fbb15
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions docs/prerender.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
# Prerender

We use [prerender](https://github.com/prerender/prerender-node) to do SEO.
`acgn-stock` can use [prerender](https://github.com/prerender/prerender-node) to help its SEO process.

But it's complicated to set, that's why we need this document.
Since the setup process is a little bit complicated, we wrote down this how-to document to help those in need.

## Get a prerender server
## Setting Up a Prerender Server

To use prerender, you need a prerender server to handle prerender request.
To enable this functionality, you will need a **prerender server** to handle the request.

You can easily use https://prerender.io/ to be prerender server.
### Hosted Service

Or, you can run your own server as follow these step.
If you don't want to run your own prerender server, check out [PrerenderIO](https://prerender.io/) for their hosted service.

### Run Your Own Prerender Server

If you choose to run your own prerender server, follow these steps:

1. install [Chrome](https://www.google.com/chrome/)

[(How to install Chrome on Ubuntu server)](https://askubuntu.com/a/79284)
[(Guide for installing Chrome on a Ubuntu server)](https://askubuntu.com/a/79284)

2. create a new node project and install [prerender](https://github.com/prerender/prerender)

2. create a new project, and install [prerender](https://github.com/prerender/prerender)
```sh
npm install prerender --save
```
**NOTE**: **Prerender server should run independently**, we don't recommend installing it in your `acgn-stock` project.
we already try it and got much error, so we remove it from this project. [(see pull request)](https://github.com/mrbigmouth/acgn-stock/pull/597)

**IMPORTANT NOTE: Don't try to install prerender server in your `acgn-stock` project!**
We tried to integrate prerender into this project (see #589, #591). Since then we encountered some serious issues which prevent `acgn-stock` from working, so we decided to remove it (see #597).
3. write `index.js`
```js
Expand All @@ -33,24 +39,23 @@ Or, you can run your own server as follow these step.
});
prerenderServer.start();
```
You can use other port, just make sure it's not be used.
[(about waitAfterLastRequest)](https://github.com/prerender/prerender#waitafterlastrequest)
For the port, we use `3900` here. Feel free to switch to the other port if you want. Just make sure it's not being used.

For the `waitAfterLastRequest`, we recommend `3000`ms here. [(Check the document about `waitAfterLastRequest`)](https://github.com/prerender/prerender#waitafterlastrequest)

4. start the server

4. run it
```sh
node index.js
```

After the server is started, you can connect to, for example, `http://localhost:3900/https://github.com/`, to see if it works.

Try to see your prerender server is working or not.
```
http://localhost:3900/https://github.com/
```

## Setting Your `acgn-stock`

## Setting your acgn-stock
Write your prerender setting in [config.json](../config.json)
Update your prerender setting in [config.json](../config.json)

```json
"prerender": {
Expand All @@ -59,11 +64,12 @@ Write your prerender setting in [config.json](../config.json)
}
```

`"use"` is prerender switch, it should be `true` if you want to use prerender.
`"use"` must be `true` if you want to use prerender.

`"url"` is the URL of the prerender server.

`"url"` is prerender server's URL.
Now you can run your `acgn-stock`, and visit the following URL to see if it's working or not.
Now you can run your acgn-stcok, and try to see prerender is working or not.
```
http://localhost:3900/company/1?_escaped_fragment_=
http://localhost:3000/company/1?_escaped_fragment_=
```

0 comments on commit 33fbb15

Please sign in to comment.