{"id":15028821,"url":"https://github.com/dwightwatson/sitemap","last_synced_at":"2025-05-14T18:02:30.796Z","repository":{"id":13704273,"uuid":"16398190","full_name":"dwightwatson/sitemap","owner":"dwightwatson","description":"Google sitemap builder for Laravel","archived":false,"fork":false,"pushed_at":"2025-03-02T11:43:54.000Z","size":193,"stargazers_count":268,"open_issues_count":10,"forks_count":42,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-14T18:02:08.325Z","etag":null,"topics":["laravel","php","sitemap"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dwightwatson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-01-31T02:56:03.000Z","updated_at":"2025-03-02T11:43:26.000Z","dependencies_parsed_at":"2025-03-25T07:00:24.971Z","dependency_job_id":null,"html_url":"https://github.com/dwightwatson/sitemap","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fsitemap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fsitemap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fsitemap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fsitemap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwightwatson","download_url":"https://codeload.github.com/dwightwatson/sitemap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198453,"owners_count":22030964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","php","sitemap"],"created_at":"2024-09-24T20:09:08.072Z","updated_at":"2025-05-14T18:02:30.766Z","avatar_url":"https://github.com/dwightwatson.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Sitemap for Laravel\n===================\n\n[![Build Status](https://travis-ci.org/dwightwatson/sitemap.png?branch=master)](https://travis-ci.org/dwightwatson/sitemap)\n[![Total Downloads](https://poser.pugx.org/watson/sitemap/downloads.svg)](https://packagist.org/packages/watson/sitemap)\n[![Latest Stable Version](https://poser.pugx.org/watson/sitemap/v/stable.svg)](https://packagist.org/packages/watson/sitemap)\n[![Latest Unstable Version](https://poser.pugx.org/watson/sitemap/v/unstable.svg)](https://packagist.org/packages/watson/sitemap)\n[![License](https://poser.pugx.org/watson/sitemap/license.svg)](https://packagist.org/packages/watson/sitemap)\n\n\nSitemap is a package built specifically for Laravel that will help you generate XML sitemaps for Google. Based on [laravel-sitemap](https://github.com/RoumenDamianoff/laravel-sitemap) this package operates in a slightly different way to better fit the needs of our project. A facade is used to access the sitemap class and we have added the ability to produce sitemap indexes as well as sitemaps. Furthermore, it's tested.\n\nRead more about sitemaps and how to use them efficiently on [Google Webmaster Tools](https://support.google.com/webmasters/answer/156184?hl=en).\n\n## Installation\n\n```sh\ncomposer require watson/sitemap\n```\n\n## Usage\n\n### Creating sitemap indexes\nIf you have a large number of links (50,000+) you will want to break your sitemaps out into seperate sitemaps with a sitemap index linking them all. You add sitemap indexes using `Sitemap::addSitemap($location, $lastModified)` and then you return the sitemap index with `Sitemap::renderSitemapIndex()`. The `$lastModified` variable will be parsed and converted to the right format for a sitemap.\n\nHere is an example controller that produces a sitemap index.\n\n```php\nnamespace App\\Http\\Controllers;\n\nuse Sitemap;\n\nclass SitemapsController extends Controller\n{\n    public function index()\n    {\n        // Get a general sitemap.\n        Sitemap::addSitemap('/sitemaps/general');\n\n        // You can use the route helpers too.\n        Sitemap::addSitemap(route('sitemaps.posts'));\n\n        // Return the sitemap to the client.\n        return Sitemap::index();\n    }\n}\n```\n\nSimply route to this as you usually would, `Route::get('sitemap', 'SitemapsController@index');`.\n\n### Creating sitemaps\nSimilarly to sitemap indexes, you just add tags for each item in your sitemap using `Sitemap::addTag($location, $lastModified, $changeFrequency, $priority)`. You can return the sitemap with `Sitemap::renderSitemap()`. Again, the `$lastModified` variable will be parsed and convered to the right format for the sitemap.\n\nIf you'd like to just get the raw XML, simply call `Sitemap::xml()`.\n\nHere is an example controller that produces a sitemap for blog posts.\n\n```php\nnamespace App\\Http\\Controllers;\n\nuse Post;\nuse Sitemap;\n\nclass SitemapsController extends Controller\n{\n    public function posts()\n    {\n        $posts = Post::all();\n\n        foreach ($posts as $post) {\n            Sitemap::addTag(route('posts.show', $post), $post-\u003eupdated_at, 'daily', '0.8');\n        }\n\n        return Sitemap::render();\n    }\n}\n```\n\nIf you just want to pass a model's `updated_at` timestamp as the last modified parameter, you can simply pass the model as the second parameter and the sitemap will use that attribute automatically.\n\n**If you're pulling a lot of records from your database you might want to consider restricting the amount of data you're getting by using the `select()` method. You can also use the `chunk()` method to only load a certain number of records at any one time as to not run out of memory.**\n\n### Image sitemaps\nYou can use Google image extensions for sitemaps to give Google more information about the images available on your pages. [Read the specification](https://support.google.com/webmasters/answer/178636?hl=en)\n\nImages are associated with page and you can use up to 1000 images per page.\n\nHere is an example of adding image tag to usual page tag.\n\n```php\nnamespace App\\Http\\Controllers;\n\nuse Page;\nuse Sitemap;\n\nclass SitemapsController extends Controller\n{\n    public function pages()\n    {\n        $pages = Page::all();\n\n        foreach ($pages as $page) {\n            $tag = Sitemap::addTag(route('pages.show', $page), $page-\u003eupdated_at, 'daily', '0.8');\n\n            foreach ($page-\u003eimages as $image) {\n                $tag-\u003eaddImage($image-\u003eurl, $image-\u003ecaption);\n            }\n        }\n\n        return Sitemap::render();\n    }\n}\n```\n\nHere is the full list of arguments to add an image to a tag.\n\n```php\n$tag-\u003eaddImage($location, $caption, $geoLocation, $title, $licenceUrl);\n```\n\n## Configuration\n\nTo publish the configuration file for the sitemap package, simply run this Artisan command:\n\n```sh\nphp artisan config:publish watson/sitemap\n\nphp artisan vendor:publish --provider=\"Watson\\Sitemap\\SitemapServiceProvider\"\n```\n\nThen take a look in `config/sitemap.php` to see what is available.\n\n### Caching\n\nBy default, caching is disabled. If you would like to enable caching, simply set `cache_enabled` in the configuration file to `true`. You can then specify how long you would like your views to be cached for. Keep in mind that when enabled, caching will affect each and every request made to the sitemap package.\n\n### Multilingual tags\n\nIf you'd like to use a mutlilingual tag, simply pass an instance of one to the `addTag` method. Below is a crude example of how you would pass alternate tag locations for different languages.\n\n```php\nSitemap::addTag(new \\Watson\\Sitemap\\Tags\\MultilingualTag(\n    $location,\n    $lastModified,\n    $changeFrequency,\n    $priority,\n    [\n        'en' =\u003e $location . '?lang=en',\n        'fr' =\u003e $location . '?lang=fr'\n    ]\n));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwightwatson%2Fsitemap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwightwatson%2Fsitemap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwightwatson%2Fsitemap/lists"}