appstract / laravel-crawl-render
Pre-render your site for web crawlers
Requires
- php: ^7.1
- jaybizzle/laravel-crawler-detect: 1.*
- spatie/crawler: ^4.0
Requires (Dev)
- phpunit/phpunit: 5.*
README
A simple package to pre-render your Javascript site for web crawlers like Google bot to improve your SEO.
It uses Spatie's Crawler and Browsershot to crawl your website and store the HTML. Crawlers (detected by Jaybizzle's Crawler Detect) are getting the pre-rendered version served.
Installation
You can install the package via composer:
composer require appstract/laravel-crawl-render
You need Puppeteer to be installed for Browsershot to work, see: https://github.com/spatie/browsershot#requirements
Usage
First add the middleware to any routes you want to Pre-render.
\Appstract\CrawlRender\Middleware\CrawlerPrerenderMiddleware::class
Then run the crawler to pre-render your site:
php artisan prerender:crawl
You can run this command regularly, for example after a deploy or with a schedule:
// app/console/Kernel.php protected function schedule(Schedule $schedule) { $schedule->command('prerender:crawl')->daily()->at('02:00'); }
Testing
composer test
Contributing
Contributions are welcome, thanks to y'all :)
About Appstract
Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.
License
The MIT License (MIT). Please see License File for more information.