feat: Enhance page SEO and language support

- Add language attributes in layout files
- Update the content-language meta tag in header files
- Introduce a custom clean_url helper to clean up URLs
- Update SEO scripts to ensure preview images display correctly
This commit is contained in:
Fechin committed 2025-06-23 01:14:33 -07:00
1 parent 641e8b512d
commit 1cc1a5d37f
4 files changed
+21 -5

No files matched your search

+4 -3
View File
@@ -1,7 +1,8 @@
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
<meta http-equiv='content-language' content='en-gb'>
<meta http-equiv='content-language' content='<%- config.language || 'en' %>'>
<meta name="language" content="<%- config.language || 'en' %>"/>
<meta name="renderer" content="webkit"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="app:pageurl" content="/"/>
@@ -14,7 +15,7 @@
<meta name="description" content="<%- page_description() %>"/>
<!-- for social -->
<meta property="og:url" content="<%- url_for(url) %>"/>
<meta property="og:url" content="<%- clean_url(url) %>"/>
<meta property="og:title" content="<%- page_title() %>"/>
<meta property="og:site_name" content="<%- config.title %>"/>
<meta property="og:description" content="<%- page_description() %>"/>
@@ -48,7 +49,7 @@
<meta name="msapplication-TileColor" content="#6366f1"/>
<!-- misc -->
<link rel="canonical" href="<%- url_for(url) %>"/>
<link rel="canonical" href="<%- clean_url(url) %>"/>
<link rel="prefetch" href="<%- url_for(config.url) %>"/>
<link rel="prerender" href="<%- url_for(config.url) %>"/>
<link rel="alternate" href="/atom.xml" title="<%- config.title %>" type="application/atom+xml"/>
+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html class="<%= is_post() ? 'scrollbar' : '' %>" translate="no">
<html class="<%= is_post() ? 'scrollbar' : '' %>" lang="<%= config.language || 'en' %>" translate="no">
<%- partial('_partial/head') %>
<body class="bg-slate-100 dark:bg-slate-900">
<%- partial('_partial/header') %>
+15
View File
@@ -3,6 +3,21 @@ const path = require('path');
hexo.extend.helper.register('icon', (name) => svgIcon(name));
// Register custom clean_url helper function
hexo.extend.helper.register('clean_url', function (url) {
if (!url) return '';
// If it's an absolute URL, convert it to a relative URL first
const cleanedUrl = this.url_for(url);
// Remove .html suffix
return cleanedUrl.replace(/(index)?\.html$/, '');
});
// Register enhanced url_for helper (optional)
hexo.extend.helper.register('url_for_clean', function (path, options = {}) {
const url = this.url_for(path, options);
return url.replace(/(index)?\.html$/, '');
});
hexo.extend.generator.register('json', (locals) => {
const searchName = 'search.json';
const datas = locals.posts.sort('date') || [];
+1 -1
View File
@@ -49,7 +49,7 @@ hexo.extend.helper.register('page_keywords', function () {
hexo.extend.helper.register('page_image', function () {
const homePng = 'preview.png';
let postPng = '';
let postPng = 'preview.png';
if (this.is_post()) {
postPng = `${this.page.slug}-preview.png`;
}