Skip to content

Improved Meta Tags - #413

Merged
XPoet merged 1 commit into
XPoet:devfrom
justaLoli:pr/feat-meta
Nov 19, 2026
Merged

XPoet merged 1 commit into
XPoet:devfrom
justaLoli:pr/feat-meta

Conversation

@justaLoli

Copy link
Copy Markdown
Contributor

现有代码问题:

  1. title标签存在多余空格和换行,干扰社媒软件渲染;
  2. meta依赖page.keywords和page.description两个front-matter,而该配置并没有在主题文档中提及,因此总是回落到默认的站点description或硬编码的”Hexo Theme Keep".

本修改

  • replace hard-coded description and keywords meta with open_graph()
  • keep the keywords meta only when page or site keywords are set
  • use page cover fields as the share image
  • add a canonical link
  • output the title on a single line

效果

修改前:

<meta name="keywords" content="Hexo Theme Keep">
<meta name="description" content="让我们期待明天会更好">
<meta name="author" content="justaLoli">
<title>
   
        Portal 2 Announcer Main Voice Lines in Chapter 1 |
    
    Loli的杂货铺
</title>
IMAGE 2026-11-19 09:30:08

修改后:

<meta name="description" content="感觉成天都在听这几句话呢,于是做了些词汇的批注">
<meta property="og:type" content="article">
<meta property="og:title" content="Portal 2 Announcer Main Voice Lines in Chapter 1">
<meta property="og:url" content="https://justalo.li/posts/50181.html">
<meta property="og:site_name" content="Loli的杂货铺">
<meta property="og:description" content="感觉成天都在听这几句话呢,于是做了些词汇的批注">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://justalo.li/posts/50181/header.jpg">
<meta property="article:published_time" content="2024-01-03T12:25:49.000Z">
<meta property="article:modified_time" content="2024-01-21T13:17:19.919Z">
<meta property="article:author" content="justaLoli">
<meta property="article:tag" content="英语">
<meta property="article:tag" content="Portal 2">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://justalo.li/posts/50181/header.jpg">
<meta name="author" content="justaLoli">
<link rel="canonical" href="https://justalo.li/posts/50181.html">
<title>Portal 2 Announcer Main Voice Lines in Chapter 1 | Loli的杂货铺</title>
IMAGE 2026-11-19 09:30:10

- replace hard-coded description and keywords meta with open_graph()
- keep the keywords meta only when page or site keywords are set
- use page cover fields as the share image via getPostCoverUrl()
- add a canonical link
- output the title on a single line
@XPoet
XPoet merged commit c34dbf3 into XPoet:dev Nov 19, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants