- What is larament/seokit used for in Laravel?
- SeoKit is a SEO toolkit for Laravel that manages meta tags, Open Graph data, Twitter cards, and JSON-LD structured data from one API. It is designed to keep metadata logic out of controllers, models, and views where possible. It supports controller-driven, model-backed, and database-backed SEO data flows.
- How do I install SeoKit in a Laravel application?
- Install it with composer require larament/seokit, then run php artisan seokit:install to publish assets. You can also publish the config and migrations manually with vendor:publish tags and run php artisan migrate. The package publishes a single seo_data migration for database-backed SEO.
- What Laravel and PHP versions does SeoKit require?
- SeoKit requires PHP 8.3 or higher and Laravel 11 or higher. Its automated tests cover Laravel 11, 12, and 13. Applications on older Laravel or PHP versions need an upgrade before adopting it.
- How do I set page meta tags from a controller with SeoKit?
- Use the SeoKit facade in your controller and chain methods such as title, description, image, and canonical. For example, SeoKit::title($post->title)->description($post->excerpt)->image($post->featured_image)->canonical(route(...)). This controller-driven flow is the quickest way to start using the package.
- Can SeoKit attach SEO metadata to Eloquent models?
- Yes, SeoKit provides a HasSeo model trait and polymorphic SEO support. Metadata is stored separately from your domain models through the seo_data table, so you can manage per-model SEO without adding columns to existing tables. This is useful for content-heavy apps such as blogs and e-commerce catalogs.
- Does SeoKit support Open Graph, Twitter cards, and JSON-LD?
- Yes, SeoKit covers meta tags, Open Graph, Twitter cards, and JSON-LD structured data. Its MetaTags class unifies these formats into a consistent API. This helps with rich snippets and social sharing without stitching together multiple packages.
- How does caching work in SeoKit?
- SeoKit includes built-in tag caching through Laravel's cache system to reduce redundant SEO queries. You still need to configure cache storage and TTL for your application. For database-backed SEO, eager load relationships with withSeo() and use aggressive caching on high-traffic pages to avoid N+1 queries.
- Is SeoKit compatible with Inertia.js?
- SeoKit has native Inertia.js support from v1.1.0 onward. Use the @seoKit Blade directive in your layouts and consider Inertia::share for global SEO values. Be careful with client-side routing and hydration mismatches when server-rendered SEO tags are involved.
- Can I use SeoKit without publishing the database migration?
- Yes, you can start with controller-driven SEO using the SeoKit facade and Blade directive without database-backed records. The seo_data migration is only needed when you want persistent, model-backed SEO metadata. This lets you adopt the package incrementally before committing to its schema.
- What should I check before adding SeoKit to a legacy Laravel app?
- Audit for existing seo or meta tables because the seo_data migration may conflict with legacy schemas. Run php artisan schema:dump before integration and test fallbackSeoData() merges with edge cases such as null versus empty strings. Also confirm the app meets the PHP 8.3 and Laravel 11 requirements.