AmazingRise / hugo-theme-diary

Moments piled up. A Hugo theme ported from SumiMakito/hexo-theme-Journal.
MIT License
568 stars 194 forks source link

Language meta label and <h1> needed for better SEO #170

Open Steven52065 opened 12 months ago

Steven52065 commented 12 months ago

Describe the bug head里好像没有元语言标签,按理说在config.toml里面设置了languageCode = 'zh-cn'后应该会添加到网页的head里面的,不过好像没有; 博文页面的标题使用的是div,好像不太适合搜索引擎识别(bing是这么说的 image

Screenshots image

Environment hugo v0.108.0-a0d64a46e36dd2f503bfd5ba1a5807b900df231d+extended windows/amd64 BuildDate=2022-12-06T13:37:56Z VendorInfo=gohugoio Chrome 117.0.5938.150(正式版本) (64 位)

Additional context 关于元语言标签,我在layouts\partials\extended_head.html 里面添加了一句 <meta http-equiv ='content-language' content ='zh-cmn-Hans'> 解决了(不过感觉直接用config.toml里面的设置会比较合理?) 关于博文页面标题,我将\themes\diary\layouts_default\single.html 的第22行( {{ .Title }} )修改为了 <h1 class="post-title">{{ .Title }}</h1> 解决了,但是这样会导致页面的格局发生一些变化...(这样改大概不太合适....) 抱歉我不太会修改这些(就不乱提pr了 QAQ ),所以希望作者可以在空闲之余修改一下,感谢。

AmazingRise commented 10 months ago

Hi @Steven52065 Thanks for your feedback. As for the language <meta> label, I'm considering to add an optional configuration in config.toml. And as for <h1>, I'll try to find a way to import it without changing the title's original style.

loikein commented 10 months ago

Please consider adding lang attribute to <html> instead of <meta> tag, as the latter is considered bad practice: Content-Language - HTTP | MDN.

FYI, PageSpeed stopped complaining after I added this in baseof.html:

<html lang="{{ default .Site.Language.LanguageCode .Params.Language }}">