- How do I export my Laravel blog to Netlify using this package?
- Run `php artisan export` to generate static HTML files in the `export` directory. Upload this folder to Netlify via their CLI or dashboard. Ensure your `public` directory (or custom asset paths) is included in the export config to retain CSS/JS. For dynamic content like blog posts, use middleware to filter sensitive routes during export.
- Will this work with Laravel 10+ and Filament admin panels?
- Yes, the package supports Laravel 7–13 and integrates seamlessly with Filament. Export only public-facing routes (e.g., `/blog/*`) while keeping Filament routes dynamic. Use the `paths()` config option to explicitly define routes to include or exclude, ensuring admin panels remain secure.
- Can I exclude certain routes (e.g., auth or API endpoints) from the static export?
- Absolutely. Use middleware like `Spatie\Export\Middleware\SkipExportMiddleware` or configure `exclude_file_patterns` in the config to block routes. Alternatively, add a header (e.g., `X-Laravel-Export: false`) to routes you want to skip during crawling.
- How do I handle dynamic content like user-specific pages in the export?
- Dynamic content (e.g., user dashboards) should be excluded by default. Use middleware to detect export requests and return static fallbacks or redirects. For blogs, pre-render content with fixed data (e.g., latest posts) or use the `paths()` method to limit exports to static-only routes.
- Does this package support Laravel Mix or Vite for asset compilation?
- Yes, but you’ll need to configure `include_files` in the export config to include compiled assets (e.g., `public/build/**`). For Vite, ensure your `vite.config.js` outputs to a directory like `public/dist`, then add it to the export’s `include_files`. Exclude `node_modules` using `exclude_file_patterns`.
- What’s the best way to test exports before deploying to production?
- Run `php artisan export` locally and validate the `export` directory for broken links, missing assets, or incorrect redirects. Use `allow_redirects: true` in config to test redirect behavior. For CI/CD, add a test step to verify the export directory structure matches expectations.
- How does this handle SEO—will canonical URLs or redirects work in static exports?
- Static exports preserve redirects if `allow_redirects: true` is set, but canonical URLs require manual checks. Test with tools like Screaming Frog to ensure no orphaned links or duplicate content. For dynamic meta tags (e.g., Open Graph), pre-render them in Blade templates or use middleware to inject static values.
- Can I automate exports in GitHub Actions for continuous deployment?
- Yes, add a workflow step like `php artisan export` followed by `netlify deploy --prod`. Use `use_streaming: true` in config to reduce memory usage for large sites. Cache dependencies (e.g., Composer) and store the export artifact for deployment.
- What are the alternatives to this package for static exports in Laravel?
- Alternatives include `spatie/laravel-static-page-generator` (simpler but less flexible) or custom solutions using Laravel’s `Artisan::call('route:list')` + `file_put_contents`. For headless CMS workflows, consider `spatie/laravel-honeypot` + static generators like Hugo. This package stands out for its Laravel-native approach and asset handling.
- How do I handle large sites with thousands of routes—will it crash my server?
- Enable `use_streaming: true` in config to process routes incrementally and reduce memory usage. For very large sites, pre-filter routes with `paths()` or use a queue system (e.g., Laravel Queues) to export in batches. Test with `php artisan export --memory=4G` to adjust limits as needed.