Installation &amp; setup | laravel-sitemap-rust | Spatie       

 SPATIE  

laravel-sitemap-rust
====================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-sitemap-rust](https://spatie.be/docs/laravel-sitemap-rust/v1)  Installation &amp; setup

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-sitemap-rust/v1) 

  Installation &amp; setup    
- [ Introduction ](https://spatie.be/docs/laravel-sitemap-rust/v1/introduction)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-sitemap-rust/v1/installation-setup)
- [ Support us ](https://spatie.be/docs/laravel-sitemap-rust/v1/support-us)
- [ Changelog ](https://spatie.be/docs/laravel-sitemap-rust/v1/changelog)
- [ Questions and issues ](https://spatie.be/docs/laravel-sitemap-rust/v1/questions-issues)
- [ Testing ](https://spatie.be/docs/laravel-sitemap-rust/v1/testing)
- [ About us ](https://spatie.be/docs/laravel-sitemap-rust/v1/about-us)

Creating sitemaps
-----------------

- [ Generating a sitemap ](https://spatie.be/docs/laravel-sitemap-rust/v1/creating-sitemaps/generating-a-sitemap)
- [ Manually creating a sitemap ](https://spatie.be/docs/laravel-sitemap-rust/v1/creating-sitemaps/manually-creating-a-sitemap)
- [ Creating a sitemap index ](https://spatie.be/docs/laravel-sitemap-rust/v1/creating-sitemaps/creating-a-sitemap-index)
- [ Splitting large sitemaps ](https://spatie.be/docs/laravel-sitemap-rust/v1/creating-sitemaps/splitting-large-sitemaps)
- [ Grouping URLs into multiple sitemaps ](https://spatie.be/docs/laravel-sitemap-rust/v1/creating-sitemaps/grouping-urls-into-multiple-sitemaps)
- [ Adding an XSL stylesheet ](https://spatie.be/docs/laravel-sitemap-rust/v1/creating-sitemaps/adding-an-xsl-stylesheet)
- [ Returning a response ](https://spatie.be/docs/laravel-sitemap-rust/v1/creating-sitemaps/returning-a-response)
- [ Sorting URLs ](https://spatie.be/docs/laravel-sitemap-rust/v1/creating-sitemaps/sorting-urls)

Customizing the crawler
-----------------------

- [ Crawl profiles ](https://spatie.be/docs/laravel-sitemap-rust/v1/customizing-the-crawler/crawl-profiles)
- [ Filtering URLs ](https://spatie.be/docs/laravel-sitemap-rust/v1/customizing-the-crawler/filtering-urls)
- [ Configuring the crawler ](https://spatie.be/docs/laravel-sitemap-rust/v1/customizing-the-crawler/configuring-the-crawler)

Adding content to URLs
----------------------

- [ Alternates ](https://spatie.be/docs/laravel-sitemap-rust/v1/adding-content-to-urls/alternates)
- [ Images ](https://spatie.be/docs/laravel-sitemap-rust/v1/adding-content-to-urls/images)
- [ Videos ](https://spatie.be/docs/laravel-sitemap-rust/v1/adding-content-to-urls/videos)
- [ News ](https://spatie.be/docs/laravel-sitemap-rust/v1/adding-content-to-urls/news)
- [ Sitemapable models ](https://spatie.be/docs/laravel-sitemap-rust/v1/adding-content-to-urls/sitemapable-models)

Advanced usage
--------------

- [ Scheduled generation ](https://spatie.be/docs/laravel-sitemap-rust/v1/advanced-usage/scheduled-generation)
- [ Writing to disks ](https://spatie.be/docs/laravel-sitemap-rust/v1/advanced-usage/writing-to-disks)
- [ Handling errors ](https://spatie.be/docs/laravel-sitemap-rust/v1/advanced-usage/handling-errors)

 Installation &amp; setup
========================

###  On this page 

1. [ Configuring the package ](#content-configuring-the-package)
2. [ Environment defaults ](#content-environment-defaults)
3. [ Customization ](#content-customization)

Add the package as a Git dependency:

```
[dependencies]
spatie-laravel-sitemap = { git = "https://github.com/spatie/laravel-sitemap-rust", branch = "main" }
laravel = { package = "laravel-rust", version = "=0.1.0", default-features = false }
```

The package requires Rust 1.99 or newer. It uses the published `laravel-rust` 0.1.0 crates, not a bundled runtime. Enable your application's framework features, such as `database-sqlite`, on its `laravel` dependency when needed.

Configuring the package
-----------------------------------------------------------------------------------------------------------------------------

You can configure the sitemap generator with `SitemapConfig`:

```
use spatie_sitemap::{SitemapConfig, SitemapGenerator};

let generator = SitemapGenerator::new("https://example.com")?
    .with_config(SitemapConfig {
        execute_javascript: false,
        chrome_binary_path: None,
        request_timeout_seconds: 10,
        connect_timeout_seconds: 10,
        allow_private_networks: false,
        public_directory: "public".into(),
    });
```

To use application configuration, register `service_provider()` and set `app.url`:

```
use laravel::Application;
use spatie_sitemap::{Sitemap, SitemapConfig, service_provider};

let app = Application::configure()
    .with_providers(|providers| { providers.add(service_provider()); })
    .with_config(|config, _| {
        config.app.url = "https://example.com".into();
        config.section_mut::<SitemapConfig>().request_timeout_seconds = 7;
    })
    .create();
app.boot().await?;
let sitemap = app.resolve::<Sitemap>().await;
```

The provider registers typed configuration and fresh `Sitemap`, `SitemapIndex`, and `SitemapGenerator` services. `public_directory` defaults to the application's public path. Application configuration runs after the defaults. Use `SitemapGenerator::from_config(app.config(), crawl_url)` when crawling a URL other than `app.url`. A generator is consumed by a crawl, so create one for each run. Database models and storage use the application's normal framework configuration.

The provider uses `spatie-laravel-package-tools`, pinned to its reviewed Git revision. Both repositories are public, so no GitHub token is required to fetch them. CI uses `SPATIE_GITHUB_TOKEN` only when it is set. Publishing to crates.io remains disabled.

Environment defaults
--------------------------------------------------------------------------------------------------------------------

The provider reads these variables through Laravel's `Env`. Invalid booleans or numbers stop startup; application configuration can override valid values.

- `SITEMAP_EXECUTE_JAVASCRIPT`: `false` by default.
- `SITEMAP_CHROME_BINARY_PATH`: optional Chrome or Chromium executable path.
- `SITEMAP_REQUEST_TIMEOUT_SECONDS`: `10` by default.
- `SITEMAP_CONNECT_TIMEOUT_SECONDS`: `10` by default.
- `SITEMAP_ALLOW_PRIVATE_NETWORKS`: `false` by default. Enable only for trusted local or intranet sites.
- `SITEMAP_PUBLIC_DIRECTORY`: the application's public directory by default.

Direct calls to `SitemapGenerator::new` use `SitemapConfig::default()`, not application configuration. Use `from_config` or resolve the provider's generator to use application settings.

Customization
-----------------------------------------------------------------------------------------------

- Implement `Sitemapable` on your application's own models. There is no package model or migration to replace.
- Use `crawl_profile` for a `CrawlPolicy` or closure, and `configure_crawler` for headers, authentication, redirects, proxies, cookies, TLS, or a custom transport.
- To share those choices throughout the application, override the transient `SitemapGenerator` binding in `with_services`. See [crawl profiles](customizing-the-crawler/crawl-profiles).
- Generation commands and queued jobs belong to the application. Register commands with Laravel's console and use Laravel jobs when queueing work; there are no package jobs or job options to override.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
