Home / Snippets / How to Generate Gzip Compressed XML Sitemaps in Laravel
How to Generate Gzip Compressed XML Sitemaps in Laravel cover

How to Generate Gzip Compressed XML Sitemaps in Laravel

636

3 years ago

0 comments

To generate a Gzip Sitemap in Laravel you can make use Laravelium/Sitemap package. If you have not read our tutorial on How to Automatically Generate Sitemap on Laravel? then do give it a read for a full step-by-step guide.

Publish Sitemap Configuration
To generate Gzip sitemap you will have to publish the sitemap configuration.
php artisan vendor:publish --provider="Laravelium\Sitemap\SitemapServiceProvider"

Update Sitemap Configuration
Now you can update whether to use the Gzip compression or not from the config from "sitemap.php" file. Set the "use_gzip" configuration to "true" and now when you generate the sitemap you will have it in "gzip" format.
<?php

/* Simple configuration file for Laravel Sitemap package */
return [
    'use_cache' => false,
    'cache_key' => 'laravel-sitemap.'.config('app.url'),
    'cache_duration' => 3600,
    'escaping' => true,
    'use_limit_size' => false,
    'max_size' => null,
    'use_styles' => true,
    'styles_location' => '/vendor/sitemap/styles/',
    'use_gzip' => true
];
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this