Download the PHP package gavtaylor/laravel-seo without Composer
On this page you can find all versions of the php package gavtaylor/laravel-seo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gavtaylor/laravel-seo
More information about gavtaylor/laravel-seo
Files in gavtaylor/laravel-seo
Package laravel-seo
Short Description One place for a Laravel site's SEO plumbing: Google Analytics and IndexNow, each switched on only when its tracking code or key is configured.
License MIT
Homepage https://github.com/gavtaylor/laravel-seo
Informations about the package laravel-seo
Laravel SEO
One package for a Laravel site's SEO plumbing. Each feature switches on only when its tracking code or key is configured, so a site uses just the parts it has set up.
| Feature | Switched on by |
|---|---|
| Google Analytics | GOOGLE_ANALYTICS_MEASUREMENT_ID |
| IndexNow | INDEXNOW_KEY |
It sits alongside gavtaylor/laravel-sitemap, which stays a separate package. If both are installed, IndexNow uses the sitemap's route scan as its URL list.
Installation
The package auto-registers. Publish the config if you want to edit it directly:
Google Analytics
Put the component in your layout's <head>:
- The Google script only loads in production by default, and never on routes matching
seo.analytics.exclude_routes(defaultadmin.*). SetGOOGLE_ANALYTICS_ENABLED=trueorfalseto override the environment check. gtag()is always defined as a harmless queue, so inline handlers likeonclick="gtag('event', ...)"never throw when tracking is off.- With no measurement ID the component outputs only that stub.
IndexNow
IndexNow tells Bing, Yandex, Naver, Seznam and others when pages change, so you do not submit URLs by hand. Google does not support it. Nothing is added to your pages: the package makes one server-side API request and serves a small key file.
Changes are detected by hashing each page's rendered HTML, not by watching source files or keeping a content database. A Blade edit, a config value, or database-driven copy that changes a page all count as a change. Only new or changed pages are submitted, as IndexNow asks.
Generate a key at https://www.bing.com/indexnow/getstarted (letters, numbers and dashes, 8-128 characters):
The package serves the key at /{key}.txt itself, so there is no file to upload. The key is public by design. Then run php artisan migrate to create the indexnow_urls table.
The first run submits every page and records its hash. Later runs submit only pages whose hash changed. If the submission fails, hashes are not saved, so the next run retries.
Run it after each deploy, and optionally on the scheduler to catch changes that happen without a deploy:
The command only contacts search engines in the production environment. Set INDEXNOW_ENABLED=true or false to override.
Where the URLs come from
If gavtaylor/laravel-sitemap is installed, its route scan is used, so there is no second list to maintain. Otherwise list absolute URLs in seo.indexnow.urls, or point seo.indexnow.url_provider at your own class implementing GavTaylor\Seo\IndexNow\Contracts\UrlProvider.
CSRF tokens, nonces and inline <svg> blocks are ignored when hashing, so a randomly rotated decorative graphic does not count as a change. List regular expressions for anything else that varies between requests (a timestamp, a random banner) in seo.indexnow.hash_ignore.
Pages are fetched over HTTP from their public URL, so the command works even when run as a user that cannot write to storage/ (for example a locked-down deploy user). Redirecting and non-200 pages are skipped. Use seo.indexnow.exclude to skip URL patterns.
Configuration
See config/seo.php; every option is commented. The environment variables are GOOGLE_ANALYTICS_MEASUREMENT_ID, GOOGLE_ANALYTICS_ENABLED, INDEXNOW_KEY, INDEXNOW_ENABLED, INDEXNOW_HOST and INDEXNOW_ENDPOINT.
Testing
License
MIT
All versions of laravel-seo with dependencies
illuminate/console Version ^12.0||^13.0
illuminate/contracts Version ^12.0||^13.0
illuminate/database Version ^12.0||^13.0
illuminate/http Version ^12.0||^13.0
illuminate/support Version ^12.0||^13.0