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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle