Download the PHP package leafs/sitemap without Composer
On this page you can find all versions of the php package leafs/sitemap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leafs/sitemap
More information about leafs/sitemap
Files in leafs/sitemap
Informations about the package sitemap
Sitemap Generator
A simple and efficient sitemap generator for Leaf apps
Sitemap Generator
Sitemap Generator is a simple and efficient tool for generating sitemaps in Leaf PHP. It helps you create XML sitemaps quickly and easily, ensuring your website is properly indexed by search engines. It generates a real sitemap.xml file in the public directory of your Leaf application, which can be accessed by search engines to crawl your website effectively, and has support for custom datasources, allowing you to generate sitemaps from various data sources such as databases, APIs, or static files.
🚀 Installation
Using Leaf CLI (Recommended):
Using Composer:
Quick Start
Once installed, your sitemap will be automatically generated based on the routes defined in your Leaf application. You can customize the sitemap generation by adding a new datasource or by adding sitemap config options directly to your routes.
Regenerating Your Sitemap
Leaf automatically generates your sitemap when it doesn’t exist.
To regenerate your sitemap, you can:
- delete the existing sitemap.xml file
- or manually generate a new one:
Auto Sitemaps
Since sitemaps automatically use your Leaf routes, you can add some config options directly to your routes to customize how they appear in the sitemap. For example:
If you have a dynamic route like /blog/{slug}, you can also add the sitemap config to the route, you can tell the sitemap generator to replace the {slug} parameter with actual values from your model if you have one defined:
This is typically a faster way to generate sitemaps for dynamic routes, as you don't have to manually add a datasource and fetch the data yourself, the sitemap generator will handle it for you. So you will only need to manually add a datasource if you want to do more complex link generation like adding multiple URLs for the same route, or if you want to add URLs that are not defined as routes in your application.
Datasources
Your application may have dynamic routes, eg: /blog/{slug}. To include these routes in your sitemap, you can create a custom datasource that fetches the necessary data from your database and adds it to the sitemap. Here's an example of how to create a custom datasource for a blog:
You can also add multiple URLs at once:
This will map the /blog/{slug} to the actual URLs of your blog posts, and include additional metadata such as last modification date, change frequency, and priority.
Add URL
The examples above show how to map existing routes to actual URLs, but you can also add new URLs that are not defined as routes in your application:
This will add the specified URLs to the sitemap without replacing any existing routes.
You can also use add without being dynamic:
If you add a URL that already exists in the sitemap, it will be replaced with the new one. For example: