Skip to content

Commit

Permalink
fix: canonical of pages without permalink is the en version
Browse files Browse the repository at this point in the history
  • Loading branch information
KentarouTakeda committed Apr 7, 2024
1 parent 8eda952 commit 7c9847e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ hexo.extend.helper.register('header_menu', function(className) {
hexo.extend.helper.register('canonical_url', function(lang) {
const slugs = this.page.path.split('/').filter(v => v !== '');

if (Object.keys(this.site.data.languages).includes(slugs.at(0))) {
if (Object.keys(this.site.data.languages).includes(slugs[0])) {
slugs.shift();
}
if (lang !== 'en') {
Expand Down
2 changes: 1 addition & 1 deletion themes/navy/layout/partial/head.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Canonical links -->
<link rel="canonical" href="{{ page.permalink }}">
<link rel="canonical" href="{{ page.permalink | default(canonical_url('en'), true) }}">
<!-- Alternate links -->
{% if page.layout == 'page' or page.layout == 'index' %}
{% for lang, value in site.data.languages %}
Expand Down

0 comments on commit 7c9847e

Please sign in to comment.