Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md According to Commit cfa3184 #565

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 2 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ Sitemap::create()

->add(Url::create('/home')
->setLastModificationDate(Carbon::yesterday())
->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
->setPriority(0.1))

->add(...)

Expand All @@ -40,8 +38,6 @@ SitemapGenerator::create('https://example.com')
->getSitemap()
->add(Url::create('/extra-page')
->setLastModificationDate(Carbon::yesterday())
->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
->setPriority(0.1))

->add(...)

Expand Down Expand Up @@ -84,9 +80,7 @@ class Post extends Model implements Sitemapable

// Return with fine-grained control:
return Url::create(route('blog.post.show', $this))
->setLastModificationDate(Carbon::create($this->updated_at))
->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
->setPriority(0.1);
->setLastModificationDate(Carbon::create($this->updated_at));
}
}
```
Expand Down Expand Up @@ -209,14 +203,10 @@ The generated sitemap will look similar to this:
<url>
<loc>https://example.com</loc>
<lastmod>2016-01-01T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://example.com/page</loc>
<lastmod>2016-01-01T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>

...
Expand Down Expand Up @@ -260,26 +250,6 @@ return [
];
```

#### Changing properties

To change the `lastmod`, `changefreq` and `priority` of the contact page:

```php
use Carbon\Carbon;
use Spatie\Sitemap\SitemapGenerator;
use Spatie\Sitemap\Tags\Url;

SitemapGenerator::create('https://example.com')
->hasCrawled(function (Url $url) {
if ($url->segment(1) === 'contact') {
$url->setPriority(0.9)
->setLastModificationDate(Carbon::create('2016', '1', '1'));
}

return $url;
})
->writeToFile($sitemapPath);
```

#### Leaving out some links

Expand Down Expand Up @@ -366,7 +336,6 @@ use Spatie\Sitemap\Tags\Url;
SitemapGenerator::create('https://example.com')
->getSitemap()
// here we add one extra link, but you can add as many as you'd like
->add(Url::create('/extra-page')->setPriority(0.5))
->writeToFile($sitemapPath);
```

Expand All @@ -381,7 +350,6 @@ use Spatie\Sitemap\Tags\Url;
SitemapGenerator::create('https://example.com')
->getSitemap()
// here we add one extra link, but you can add as many as you'd like
->add(Url::create('/extra-page')->setPriority(0.5)->addAlternate('/extra-pagina', 'nl'))
->writeToFile($sitemapPath);
```

Expand Down Expand Up @@ -559,6 +527,7 @@ protected function schedule(Schedule $schedule)
$schedule->command('sitemap:generate')->daily();
...
}

```

## Changelog
Expand Down