diff --git a/layout/_partials/head/head-unique.njk b/layout/_partials/head/head-unique.njk
index 7aa8308..5424909 100644
--- a/layout/_partials/head/head-unique.njk
+++ b/layout/_partials/head/head-unique.njk
@@ -1,6 +1,11 @@
{{ open_graph() }}
-{{ canonical() }}
+{# https://github.com/theme-next/hexo-theme-next/issues/866 #}
+{%- set canonical = url | replace(r/index\.html$/, '') %}
+{%- if not config.permalink.endsWith('.html') %}
+ {%- set canonical = canonical | replace(r/\.html$/, '') %}
+{%- endif %}
+
{# Exports some front-matter variables to Front-End #}
`;
});
@@ -59,20 +58,9 @@ hexo.extend.helper.register('post_nav', function(post) {
hexo.extend.helper.register('gitalk_md5', function(path) {
const str = this.url_for(path);
- str.replace('index.html', '');
return crypto.createHash('md5').update(str).digest('hex');
});
-hexo.extend.helper.register('canonical', function() {
- // https://support.google.com/webmasters/answer/139066
- const { permalink } = hexo.config;
- let url = this.url.replace(/index\.html$/, '');
- if (!permalink.endsWith('.html')) {
- url = url.replace(/\.html$/, '');
- }
- return ``;
-});
-
/**
* Get page path given a certain language tag
*/