Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Filament Seo Laravel Package

ralphjsmit/laravel-filament-seo

Filament field group for editing laravel-seo metadata (title, author, description). Automatically loads/saves via the model’s seo() relationship—just add HasSEO to your Eloquent model and drop SEO::make() into any Filament form.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require ralphjsmit/laravel-filament-seo
    

    Publish the config file:

    php artisan vendor:publish --provider="RalphJSmit\FilamentSEO\FilamentSEOServiceProvider" --tag="filament-seo-config"
    
  2. Configure SEO Fields Edit config/filament-seo.php to define default SEO fields (e.g., title, description, keywords, meta_tags).

  3. Add to a Filament Resource Use the HasSEO trait in your Filament resource (compatible with Laravel 10+ and now Laravel 13):

    use RalphJSmit\FilamentSEO\Concerns\HasSEO;
    
    class PageResource extends Resource
    {
        use HasSEO;
    
        // ...
    }
    
  4. First Use Case Access SEO fields in your Filament panel via the "SEO" tab (auto-generated). Edit meta tags directly from the admin UI.


Implementation Patterns

Workflow: Managing SEO for Dynamic Content

  1. Resource Integration Extend any Filament resource with HasSEO to expose SEO fields:

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                // ... other fields
                SEOFields::make(),
            ]);
    }
    
  2. Customizing SEO Fields Override defaults in config/filament-seo.php or dynamically:

    SEOFields::make([
        'title' => 'Custom Title Field',
        'description' => 'Custom Description',
        'canonical' => 'Canonical URL',
    ]);
    
  3. Conditional SEO Hide/show SEO fields based on logic:

    SEOFields::make()->visible(fn ($record) => $record->is_published)
    
  4. Syncing with Laravel SEO Use the underlying spatie/laravel-seo package for model binding (ensure compatibility with Laravel 13):

    public static function getRelations(): array
    {
        return [
            Seo::class, // Spatie's SEO model
        ];
    }
    
  5. Bulk SEO Updates Leverage Filament’s bulk actions to update SEO metadata for multiple records:

    public static function table(Table $table): Table
    {
        return $table
            ->actions([
                Tables\Actions\EditAction::make(),
                SEOBulkAction::make(), // Hypothetical bulk SEO editor
            ]);
    }
    

Gotchas and Tips

Pitfalls

  1. Missing Config Forgetting to publish the config (filament-seo.php) will default to empty SEO fields. Always run:

    php artisan vendor:publish --tag="filament-seo-config"
    
  2. Laravel 13 Compatibility Ensure your project is upgraded to Laravel 13 if leveraging new features. Test thoroughly for any breaking changes in Filament or Spatie packages.

  3. Model Binding Conflicts If using spatie/laravel-seo, ensure your model’s seo() relationship matches the package’s expectations:

    public function seo()
    {
        return $this->morphOne(Seo::class, 'model');
    }
    
  4. Caching Issues SEO fields may not reflect changes immediately due to Filament’s caching. Clear the view cache:

    php artisan view:clear
    
  5. Overriding Defaults Customizing SEO fields via config/filament-seo.php does not automatically update existing database records. Use migrations or seeders to backfill data:

    Seo::create([
        'title' => 'Default Title',
        'description' => 'Default Description',
        'model_type' => YourModel::class,
        'model_id' => $record->id,
    ]);
    

Debugging Tips

  • Check the UI: If SEO fields don’t appear, verify the HasSEO trait is used and the resource’s form() includes SEOFields::make().
  • Log SEO Data: Temporarily add a dd() in your model’s seo() relationship to inspect bound data.
  • Filament Panel Refresh: Hard-refresh the Filament panel (Ctrl+F5) to bypass cached views.
  • Laravel 13 Debugging: Use php artisan optimize:clear if encountering issues with new Laravel 13 features.

Extension Points

  1. Custom SEO Fields Extend the SEOFields class to add custom meta tags:

    class CustomSEOFields extends SEOFields
    {
        public static function make(): array
        {
            return array_merge(parent::make(), [
                TextInput::make('twitter_card')->label('Twitter Card'),
            ]);
        }
    }
    
  2. Validation Rules Add validation to SEO fields in your resource’s form():

    SEOFields::make()->columns(2)
        ->rules([
            'title' => 'required|max:60',
            'description' => 'required|max:160',
        ]),
    
  3. SEO Preview Integrate with a package like spatie/laravel-honeypot to preview SEO changes in real-time:

    public static function table(Table $table): Table
    {
        return $table->columns([
            // ...
            Tables\Columns\TextColumn::make('seo_preview')
                ->view('filament-seo::preview', ['seo' => fn ($record) => $record->seo]),
        ]);
    }
    
  4. Localization Use Filament’s localization features to support multi-language SEO:

    SEOFields::make()->translatable([
        'title', 'description', 'keywords',
    ]);
    
  5. Laravel 13 Features Leverage new Laravel 13 features like app models or improved routing for enhanced SEO management:

    // Example: Using app models for cleaner SEO model binding
    public function seo()
    {
        return $this->morphOne(app(Seo::class), 'model');
    }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity