Search code examples
angularprerender

Angular 2 SEO with Pre-Render.io


Basically I want to use Pre-Render.io for my Angular 2 application and I am new to it, I have gone through the Doc of Pre-Render.io But I only able to get this Pre-Render.io to work with Angular 1, I am unable to get it work with Angular 2, I am not getting any error messages also. It will be very helpful if I get any other doc or video tutorials or example for how to use Pre-Render.io with Angular 2.


Solution

  • This is not really an angular question because you don't have to do anything with your angular app in order for it to work. Only a simple metatag needs to be added to the index file.

    Follow these steps:

    • Step 1

    Add this to your angular app:

    <meta name="fragment" content="!">
    
    • Step 2

    Run npm install prerender-node --save in your node project (or whatever you're using)

    • Step 3

    Add this to your server (or equivalent if you're not using node):

    app.use(require('prerender-node'));
    
    • Step 4

    Configurate nginx or whatever you're using to redirect the crawlers to your fragmented site. This is outside of my knowledge base however so any questions regarding this should be opened as a new question if you're unsure about how to do it.