A team has implemented a web application using MySql, PHP with the Zend framework and Angular.js on the client side. I am in charge of implementing the SEO for this application.
I understand I have to take HTML snapshots of the Angular pages and serve them to web crawlers. That's the only solution working for search engines not executing Javascript.
How can I take such snapshots efficiently? I mean, is there a PHP-related tool that can help me? Should I call a tool from PHP? If yes, which one?
Had this application been developed with
node.js
, I might have used something like Grunt'sgrunt-html-snapshot
. Is there an equivalent for the Zend framework?Would you recommend I take snapshots once for all, or should I generate them dynamically? The content of the website does not change that often. It is not critical to have the latest content for SEO purposes.
1 Answer 1
Totally depends on your application. I've seen a few commercial solutions:
https://prerender.io middleware, which works with Zend Framework2. It's free for under 250 "pages" and works if 7-day caching is acceptable.
Also, check out Brombone.
If you want to go manual, you'll need to do a few things (details here):
- Set up hashbang (#!) syntax and HTML5 mode with
$location
service - Add
<meta name="fragment" content="!">
to your html header, which tells Google (and others) to crawl the site using the?_escaped_fragment_=
tag - You can then parse the escaped fragment on the backend to serve some sort of static rendering