Search code examples
javascriptnode.jsnginxseometa-tags

Prerender angular2 pages as pure HTML


My problem is that facebook and twitter bots do not execute javascript, and I need metatags in my items, so that the right image/title/message is displayed when sharing on those platforms.

I have a nginx server serving angular2 content as static files.

Now I want to somehow prerender the pages for those bots. More specifically, I want to redirect the bots to an instance of for example phantomJS which would prerender the pages. I want that instance to run as a separate service on a different IP so that I can perhaps re-use it for something else too.

I have no idea where and how to start. Are there any nodejs server packages, who would already know how to do that for me?


Solution

  • Ended up installing a self-hosted version of prerender (https://github.com/prerender/prerender) and routed the bots to it through nginx. Works great!