Skip to content

Commit

Permalink
Merge branch 'release/5.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jun 17, 2024
2 parents cda7953 + 3384ad3 commit 149f36f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v5.1.0
## 06/17/24

1. [](#new)
* Added page-level `lastmod` options [#113](https://github.com/getgrav/grav-plugin-sitemap/pull/113)
1. [](#improved)
* Updated README.md with page override options.

# v5.0.0
## 10/05/2023

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ sitemap:
ignore: true
```
## Overrides
You can override several elements of the sitemap entry for the page in the page's header. For example, as well as `ignore` mentioned above, these are available:

```yaml
sitemap:
lastmod: # e.g. '2024-04-17'
changefreq: # always| hourly | daily: | weekly | monthly | yearly | never
priority: # 0.1 -> 1.0
```

## Multi-Language Support

The latest Sitemap `v3.0` includes all new multi-language support utilizing the latest [Google Search SEO Recomendations](https://developers.google.com/search/docs/advanced/crawling/localized-versions?hl=en&visit_id=637468720624267418-280936473&rd=2) which creates bi-directional `hreflang` entries for each language available.
Expand All @@ -98,6 +109,7 @@ https://yoursite.com/blog/sitemap-news.xml

You can change the "News Path" to be something other than `sitemap-news.xml` if you wish.


## Images

You can add images to the sitemap by adding an entry in the page's Frontmatter.
Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Sitemap
type: plugin
slug: sitemap
version: 5.0.0
version: 5.1.0
description: "Provide automatically generated **XML sitemaps** with this very useful, as a simple to configure Grav plugin."
icon: map-marker
author:
Expand Down
5 changes: 5 additions & 0 deletions blueprints/sitemap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ form:
type: bool
required: false

header.sitemap.lastmod:
type: datetime
label: PLUGIN_SITEMAP.HEADER_LASTMOD
default: ''

header.sitemap.changefreq:
type: select
label: PLUGIN_SITEMAP.HEADER_CHANGEFREQ
Expand Down
1 change: 1 addition & 0 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ en:
PLUGIN_SITEMAP:
SITEMAP: 'Sitemap'
HEADER_IGNORE: 'Sitemap ignore page'
HEADER_LASTMOD: 'Sitemap Last Modified'
HEADER_CHANGEFREQ: 'Sitemap Change Frequency'
HEADER_PRIORITY: 'Sitemap priority'
CHANGEFREQ: 'Global - Sitemap Change Frequency'
Expand Down
3 changes: 2 additions & 1 deletion sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ protected function addRouteData($pages, $lang)
$include_lang = $this->multilang_skiplang_prefix !== $lang;
$location = $page->canonical($include_lang);
$url = $page->url(false, $include_lang);
$lastmod = !empty($header->sitemap['lastmod']) ? strtotime($header->sitemap['lastmod']) : $page->modified();

$lang_route = [
'title' => $page->title(),
Expand All @@ -318,7 +319,7 @@ protected function addRouteData($pages, $lang)
'lang' => $lang,
'translated' => in_array($lang, $page_languages),
'location' => $location,
'lastmod' => date($this->datetime_format, $page->modified()),
'lastmod' => date($this->datetime_format, $lastmod),
'longdate' => date('Y-m-d\TH:i:sP', $page->date()),
'shortdate' => date('Y-m-d', $page->date()),
'timestamp' => $page->date(),
Expand Down

0 comments on commit 149f36f

Please sign in to comment.