# static export

Stancy integrates [spatie/laravel-export](https://github.com/spatie/laravel-export) to export your pages as static files.

## Configuration

We recommend to disable the `crawl` option and export only listed paths/pages. The `paths` option can be empty if you only want to export feeds and/or pages. But you also can add additional paths, like the sitemap, to export.

{% code title="config/export.php" %}

```php
<?php

return [
    // to only export listed paths/pages
    'crawl' => false,

    'paths' => [
        '/sitemap.xml',
    ],
];
```

{% endcode %}

## prepare Pages

By default you can't export any page, only the feeds. To allow page export you have to implement the `\Astrotomic\Stancy\Contracts\Routable` interface in your [page data class](/stancy/basics/pagedata.md). This interface is also good to add your pages to a [sitemap](/stancy/advanced/sitemap.md) and [feeds](/stancy/advanced/feed.md).

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

```php
<?php

namespace App\Pages;

use Astrotomic\Stancy\Contracts\Routable;
use Astrotomic\Stancy\Models\PageData;

class Home extends PageData implements Routable
{
    public function getUrl(): string
    {
        return url('/');
    }
}
```

{% endcode %}

## ExportFactory

To add your pages programmatically you should use a service provider. This service provider should be the last or at least after `\App\Providers\RouteServiceProvider` in your `app.providers` configuration. In the service provider you should use the `boot()` method where you can inject the `\Astrotomic\Stancy\Contracts\ExportFactory` service and add a new `booted` event listener.

{% code title="app/Providers/ExportServiceProvider.php" %}

```php
<?php

namespace App\Providers;

use Astrotomic\Stancy\Contracts\ExportFactory as ExportFactoryContract;
use Illuminate\Support\ServiceProvider;

class ExportServiceProvider extends ServiceProvider
{
    public function boot(ExportFactoryContract $exportFactory)
    {
        $this->app->booted(function () use ($exportFactory) {
            $exportFactory
                ->addFeeds()
                ->addSheetList(['static:home', 'static:blog'])
                ->addSheetCollectionName('blog')
            ;
        });
    }
}
```

{% endcode %}

This service provider will add all [feeds](/stancy/advanced/feed.md), blog posts and the `home` and `blog` static pages.


---

# Agent Instructions: 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:

```
GET https://docs.astrotomic.info/stancy/advanced/static-export.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
