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 Sitemap Laravel Package

spatie/laravel-sitemap

Generate XML sitemaps for Laravel by crawling your site or building them manually. Add extra URLs, set last-modified dates, and include models via a simple interface. Write sitemaps to disk with a fluent, developer-friendly API.

View on GitHub
Deep Wiki
Context7

title: Sorting URLs weight: 7

You can sort the URLs in your sitemap alphabetically using the sort() method. This is useful for maintaining a consistent order in your sitemap files.

use Spatie\Sitemap\Sitemap;

$sitemap = Sitemap::create()
    ->add('/zoo')
    ->add('/blog')
    ->add('/about')
    ->add('/contact')
    ->sort();

The sort() method will arrange all URLs in alphabetical order.

Case Sensitivity

The sort operation is case-sensitive, with uppercase letters sorted before lowercase letters. For example:

$sitemap = Sitemap::create()
    ->add('/Zebra')
    ->add('/apple')
    ->add('/BANANA')
    ->sort();

// Results in order: /BANANA, /Zebra, /apple

Method Chaining

The sort() method returns the sitemap instance, allowing you to chain it with other methods:

$sitemap = Sitemap::create()
    ->add('/page1')
    ->add('/page3')
    ->add('/page2')
    ->sort()
    ->writeToFile(public_path('sitemap.xml'));
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope