Skip to content

Commit 789a486

Browse files
committedAug 8, 2024
README
1 parent 62b1fbd commit 789a486

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed
 

‎README.md

+53-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
PHP Simple Sitemap Generator. Follows the [W3C Sitemap Protocol](http://www.sitemaps.org/protocol.html)
44

5+
<!-- TOC -->
6+
* [PHP Sitemap](#php-sitemap)
7+
* [Installation via Composer](#installation-via-composer)
8+
* [Getting Started](#getting-started)
9+
* [Render it to XML:](#render-it-to-xml)
10+
* [Arguments](#arguments)
11+
* [loc](#loc)
12+
* [changefreq](#changefreq)
13+
* [priority](#priority)
14+
* [lastmod](#lastmod)
15+
* [Google News Sitemap](#google-news-sitemap)
16+
* [Using Sitemap index files (to group multiple sitemap files)](#using-sitemap-index-files-to-group-multiple-sitemap-files)
17+
* [More](#more)
18+
<!-- TOC -->
19+
520
## Installation via Composer
621

722
```shell
@@ -86,7 +101,7 @@ return $response;
86101

87102
The XML output in browser:
88103

89-
``` xml
104+
```xml
90105
<?xml version="1.0" encoding="utf-8"?>
91106
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
92107
<url>
@@ -159,6 +174,42 @@ $sitemap->setDateFormat(\DateTimeInterface::ISO8601);
159174
$sitemap->setDateFormat('Y-m-d');
160175
```
161176

177+
## Google News Sitemap
178+
179+
Please see [Google News Sitemap](https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap?visit_id=637247859078479568-4208069007&rd=3) document.
180+
181+
```php
182+
$sitemap = new \Asika\Sitemap\NewsSitemap();
183+
184+
$sitemap->addItem(
185+
$url,
186+
$newsTitle,
187+
'Publication Name',
188+
'en-us',
189+
$publishedDate
190+
);
191+
```
192+
193+
The format:
194+
195+
```xml
196+
<?xml version="1.0" encoding="UTF-8"?>
197+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
198+
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
199+
<url>
200+
<loc>http://www.example.org/business/article55.html</loc>
201+
<news:news>
202+
<news:publication>
203+
<news:name>The Example Times</news:name>
204+
<news:language>en</news:language>
205+
</news:publication>
206+
<news:publication_date>2008-12-23</news:publication_date>
207+
<news:title>Companies A, B in Merger Talks</news:title>
208+
</news:news>
209+
</url>
210+
</urlset>
211+
```
212+
162213
## Using Sitemap index files (to group multiple sitemap files)
163214

164215
```php
@@ -174,7 +225,7 @@ echo $index->render();
174225

175226
Output:
176227

177-
``` xml
228+
```xml
178229
<?xml version="1.0" encoding="utf-8"?>
179230
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
180231
<sitemap>

0 commit comments

Comments
 (0)