2
2
3
3
PHP Simple Sitemap Generator. Follows the [ W3C Sitemap Protocol] ( http://www.sitemaps.org/protocol.html )
4
4
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
+
5
20
## Installation via Composer
6
21
7
22
``` shell
@@ -86,7 +101,7 @@ return $response;
86
101
87
102
The XML output in browser:
88
103
89
- ``` xml
104
+ ``` xml
90
105
<?xml version =" 1.0" encoding =" utf-8" ?>
91
106
<urlset xmlns =" http://www.sitemaps.org/schemas/sitemap/0.9" >
92
107
<url >
@@ -159,6 +174,42 @@ $sitemap->setDateFormat(\DateTimeInterface::ISO8601);
159
174
$sitemap->setDateFormat('Y-m-d');
160
175
```
161
176
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
+
162
213
## Using Sitemap index files (to group multiple sitemap files)
163
214
164
215
``` php
@@ -174,7 +225,7 @@ echo $index->render();
174
225
175
226
Output:
176
227
177
- ``` xml
228
+ ``` xml
178
229
<?xml version =" 1.0" encoding =" utf-8" ?>
179
230
<sitemapindex xmlns =" http://www.sitemaps.org/schemas/sitemap/0.9" >
180
231
<sitemap >
0 commit comments