Generate a sitemap

Fund package maintenance!

Installs: 12 119

Dependents: 2

Suggesters: 6

Security: 0

Stars: 11

Watchers: 5

Forks: 15

Open Issues: 4


1.0.3 2022-01-17 19:36 UTC


MIT license Latest Stable Version Total Downloads OpenCollective

This extension simply adds a sitemap to your forum.

It uses default entries like Discussions and Users, but is also smart enough to conditionally add further entries based on the availability of extensions. This currently applies to flarum/tags and fof/pages. Other extensions can easily inject their own Resource information, check Extending below.


There are several modes to use the sitemap.

Runtime mode

After enabling the extension the sitemap will automatically be available and generated on the fly. It contains all Users, Discussions, Tags and Pages guests have access to.

Applicable to small forums, most likely on shared hosting environments, with discussions, users, tags and pages summed up being less than 10.000 items.

Cache or disk mode

You can set up a cron job that stores the sitemap into cache or onto disk. You need to run:

php flarum fof:sitemap:cache

To store the sitemap into cache. If you want to save the sitemap directly to your public folder, use the flag:

php flarum fof:sitemap:cache --write-xml-file

Best for small forums, most likely on hosting environments allowing cronjobs and with discussions, users, tags and pages summed up being less than 50.000 items.

50.000 is the technical limit for sitemap files. If you have more entries to store, use the following option!

Multi file mode

For larger forums you can set up a cron job that generates a sitemap index and compressed sitemap files.

php flarum fof:sitemap:multi

This command creates temporary files in your storage folder and if successful moves them over to the public directory automatically.

Best for larger forums, starting at 50.000 items.


Register a new Resource

In order to register your own resource, create a class that implements FoF\Sitemap\Resources\Resource. Make sure to implement all abstract methods, check other implementations for examples. After this, register your

return [
    new \FoF\Sitemap\Extend\RegisterResource(YourResource::class),

That's it.

Remove a Resource

In a very similar way, you can also remove resources from the sitemap:

return [
    (new \FoF\Sitemap\Extend\RemoveResource(\FoF\Sitemap\Resources\User::class)),


If the size of your forum requires one of the cache modes - either in-memory or disk, consider setting up the Flarum scheduler. Read more information about this here


The initial version of this extension was sponsored by


Install manually with composer:

composer require fof/sitemap


composer update fof/sitemap
php flarum migrate
php flarum cache:clear

Nginx issues

If you are using nginx and accessing /sitemap.xml results in an nginx 404 page, you can add the following rule to your configuration file, underneath your existing location rule:

location = /sitemap.xml {
    try_files $uri $uri/ /index.php?$query_string;

This rule makes sure that Flarum will answer the request for /sitemap.xml when no file exists with that name.