You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Just the Docs Jekyll主题中修改首页Meta标题且不改动显示标题

解决Just the Docs主题单独修改首页Meta标题的方法

可以实现,无需改动全局_config.yml里的title配置,也不会影响前端显示的标题,具体操作如下:

  • 复制主题默认的_includes/head.html文件到你自己的项目目录下(避免直接修改主题源文件)。
  • 在复制后的head.html中找到生成<title>标签的代码块,修改为针对首页的判断逻辑:
    {% if page.url == "/" %}
      <title>你的自定义首页Meta标题 - Lea Bosshart Text</title>
    {% else %}
      <title>{{ page.title | default: site.title }}</title>
    {% endif %}
    
  • 若想更灵活,可在首页的index.md文件的YAML前置区域添加自定义字段:
    ---
    layout: home
    meta_title: 你的自定义首页标题
    ---
    
    再把head.html里的标题逻辑改成:
    <title>{{ page.meta_title | default: page.title | default: site.title }}</title>
    
    这样只有首页会调用自定义的meta_title,其他页面保持原有规则,同时完全不影响前端显示的标题。

内容的提问来源于stack exchange,提问作者aronsommer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 16:35:07