> For the complete documentation index, see [llms.txt](https://docs.astrotomic.info/stancy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.astrotomic.info/stancy/advanced/sitemap.md).

# Sitemap

Stancy can generate a sitemap using [spatie/laravel-sitemap](https://github.com/spatie/laravel-sitemap). It allows you to add whole collections but also single pages to a sitemap.

## prepare Pages

By default you can't add a page to your sitemap. You have to use a `\Astrotomic\Stancy\Models\PageData` class which defines the `toSitemapItem()` method. The easiest way is to use the `\Astrotomic\Stancy\Contracts\Routable` interface and `\Astrotomic\Stancy\Traits\PageHasUrl` trait. After this you only have to define the `getUrl()` method which is also useful to add the page to a [feed](/stancy/advanced/feed.md) or generate a link to it in a view.

{% code title="app/Pages/Post.php" %}

```php
<?php

namespace App\Pages;

use Astrotomic\Stancy\Contracts\Routable;
use Astrotomic\Stancy\Models\PageData;
use Astrotomic\Stancy\Traits\PageHasContent;
use Astrotomic\Stancy\Traits\PageHasSlug;
use Astrotomic\Stancy\Traits\PageHasUrl;

class Post extends PageData implements Routable
{
    use PageHasSlug, PageHasContent, PageHasUrl;

    public function getUrl(): string
    {
        return route('blog.post', ['post' => $this->slug]);
    }
}
```

{% endcode %}

## Sitemap response

The following code snippet will show you how to return a sitemap within your routes. The sitemap will contain all pages in the `static` and `blog` collection.

{% code title="routes/web.php" %}

```php
<?php

use Astrotomic\Stancy\Facades\SitemapFactory;

Route::get('/sitemap.xml', function () {
    return SitemapFactory::makeFromSheetList(['static', 'blog']);
});
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.astrotomic.info/stancy/advanced/sitemap.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
