• 简体中文
  • 配置参考

    本文档详细说明 _config.modernduang.yml 中的每一个配置选项。每个章节对应配置文件中的一个顶级键。

    favicon

    站点 favicon 路径。

    favicon: /img/favicon.ico
    属性类型描述
    faviconstringfavicon 文件路径

    导航菜单配置。每个键为菜单标签,值为 URL 字符串或包含扩展选项的对象。

    menu:
      首页: /
      归档: /archives
      标签: /tags
      分类: /categories
      友链: /links
      GitHub:
        url: https://github.com/yourname
        external: true

    简单菜单项

    键值对形式,值为 URL 字符串。使用与键名匹配的内置图标。

    menu:
      首页: /

    扩展菜单项

    带有额外选项的对象:

    menu:
      GitHub:
        url: https://github.com/yourname
        icon: '<svg viewBox="0 0 24 24">...</svg>'  # 自定义 SVG 图标(可选)
        external: true                                # 在新标签页打开(可选)

    下拉菜单

    带有嵌套 children 的菜单项:

    menu:
      项目:
        icon: '<svg>...</svg>'  # 可选的父级图标
        children:
          项目A: /project-a
          项目B:
            url: https://external.com
            external: true

    内置图标

    以下菜单名称具有内置 SVG 图标:首页归档标签分类友链开往关于

    自定义菜单名称请通过 icon 属性提供自己的 SVG。

    属性类型默认值描述
    urlstring链接地址
    iconstring自定义 SVG 图标字符串
    externalbooleanfalse是否在新标签页打开
    childrenobject嵌套子菜单项

    dark_mode

    暗色模式配置。

    dark_mode:
      enable: true
      default: light
    属性类型默认值描述
    enablebooleantrue是否启用暗色模式切换
    defaultstring'light'默认配色方案('light' | 'dark'

    font

    Google Fonts 字体集成。

    font:
      enable: true
      host: https://fonts.googleapis.com
      global:
        external: true
        families:
          - Fredoka:wght@400;500;600;700
          - Nunito:wght@300;400;500;600
          - JetBrains+Mono:wght@400;500
    属性类型默认值描述
    enablebooleantrue是否启用 Google Fonts 加载
    hoststring'https://fonts.googleapis.com'字体 CDN 主机(国内可改用镜像)
    global.externalbooleantrue作为外部样式表加载
    global.familiesstring[]要加载的 Google Font 字体族

    comments

    评论系统配置。目前仅支持 Twikoo

    comments:
      enable: false
      twikoo:
        envId: https://your-twikoo-envid
        region: ap-shanghai
    属性类型默认值描述
    enablebooleanfalse是否全局启用评论功能
    twikoo.envIdstring''你的 Twikoo 环境 ID(URL)
    twikoo.regionstring'ap-shanghai'Twikoo 云区域

    提示: 在文章 Front Matter 中设置 comment: false 可禁用单篇文章的评论。


    页脚配置。

    footer:
      since: 2024
      author: 你的名字
      powered: true
      social:
        travelling: true
        github: true
        email: false
        custom: []
      custom: ''
      beian:
        icp: ''
        moe: ''
        chabei: ''

    基础页脚选项

    属性类型默认值描述
    sincenumber站点建立年份
    authorstring''站点作者名称
    poweredbooleantrue显示"Powered by Hexo & ModernDuang"

    页脚社交图标

    属性类型默认值描述
    social.travellingbooleantrue显示"开往"友链接力图标
    social.githubbooleantrue显示 GitHub 图标(使用 profile.social 中的 GitHub 链接)
    social.emailbooleanfalse显示 Email 图标(使用 profile.social 中的 Email 链接)
    social.customarray[]自定义社交图标项

    每个自定义社交图标项:

    social:
      custom:
        - name: RSS
          url: /atom.xml
          icon: rss                    # 内置图标名或 SVG 字符串
          color: '#FF6600'             # 可选的悬停背景颜色

    自定义页脚 HTML

    footer:
      custom: '<p>你的自定义 HTML 内容</p>'

    ICP 备案

    footer:
      beian:
        icp: "京ICP备12345678号"    # 工信部备案号(完整格式)
        moe: "123456"                # 萌备案号(只填数字)
        chabei: "123456"             # 茶备案号(只填数字)
    属性类型默认值描述
    beian.icpstring''工信部 ICP 备案号(完整格式)
    beian.moestring''萌备案号(只填数字,显示为"萌ICP备XXXXXX号",官方:icp.gov.moe
    beian.chabeistring''茶备案号(只填数字,显示为"茶ICP备XXXXXX号",官方:icp.redcha.cn

    siteInfo

    友链页面展示的站点信息。

    siteInfo:
      url: https://yourblog.com
      avatar: https://yourblog.com/avatar.png
      atom: https://yourblog.com/atom.xml
    属性类型默认值描述
    urlstring''你的站点 URL
    avatarstring''你的站点头像/Logo
    atomstring''你的 Atom 订阅地址

    站点 namedescription 会自动从 Hexo 主配置 _config.yml 继承。


    hero

    首页 Hero 区域配置。

    hero:
      mode: fixed
      text: 欢迎来到我的博客
      texts:
        - 欢迎来到我的博客
        - 用文字记录思考,用代码改变世界
    属性类型默认值描述
    modestring'fixed'显示模式:'fixed'(固定)或 'random'(随机)
    textstring副标题文字(固定模式使用)
    textsstring[]副标题池(随机模式使用)

    固定模式: 始终显示 text 的值。

    随机模式: 每次页面加载时从 texts 数组中随机选取一条。


    plans

    首页展示的年度计划/目标。

    plans:
      - text: 完成自定义博客主题的开发
        done: true
        current: 1
        final: 1
      - text: 至少撰写10篇博客
        done: false
        current: 7
        final: 10
    属性类型默认值描述
    textstring计划/目标描述
    donebooleanfalse是否已完成
    currentnumber0当前进度数
    finalnumber1目标总数

    首页会显示总体进度条和各项计划。当 done: true 时显示勾选标记。当 final > 1 时显示进度标签(current/final)。


    profile

    首页展示的个人信息卡片。

    profile:
      avatar: https://your-avatar-url.png
      motto: Enjoy the moment
      social:
        - name: GitHub
          url: https://github.com/yourname
          icon: github
        - name: Bilibili
          url: https://space.bilibili.com/12345
          icon: bilibili
    属性类型默认值描述
    avatarstring''头像图片 URL
    mottostring''个人座右铭/格言
    socialarray[]社交媒体链接

    社交链接项

    属性类型描述
    namestring显示名称
    urlstring链接地址
    iconstring内置图标名或自定义 SVG 字符串

    完整的内置图标名列表请参阅 社交图标 页面。


    friendGroups

    友链页面分组。

    friendGroups:
      技术伙伴: 🌟
      生活: 🎨
      朋友们: 🤝

    每个键为分组名称,值为 emoji 图标。


    tags

    标签页配置。

    tags:
      icon: ''  # 标签页标题自定义 SVG 图标
    属性类型默认值描述
    iconstring''标签页自定义图标(空 = 默认 # 图标)

    categories

    分类页配置。为特定分类定义自定义样式。

    categories:
      技术:
        desc: 探索前沿技术
        icon: '<svg viewBox="0 0 24 24">...</svg>'
        color: 'var(--pastel-blue)'
        textColor: '#3A7CA5'
    属性类型默认值描述
    descstring分类描述
    iconstring自定义 SVG 图标
    colorstring背景颜色(CSS 值)
    textColorstring图标文字颜色

    未匹配的分类将使用默认样式,颜色自动轮换。


    friends

    友链列表。

    friends:
      - name: 示例博客
        url: https://example.com
        desc: 一个很棒的博客
        avatar: https://example.com/avatar.png
        group: 技术伙伴
    属性类型描述
    namestring友链站点名称
    urlstring友链站点 URL
    descstring简短描述
    avatarstring头像图片 URL
    groupstring分组名称(需与 friendGroups 中的键匹配)

    siteStats

    首页展示的站点数据。

    siteStats:
      enable: false
      startDate: '2024-01-01'
    属性类型默认值描述
    enablebooleanfalse是否在首页展示站点数据板块
    startDatestring'2024-01-01'站点起始日期(YYYY-MM-DD 格式)

    首页展示:

    • 运行时长 — 自 startDate 以来的年数和天数
    • 十年之约倒计时 — 自动计算为 startDate + 10 年,显示剩余百分比

    完整配置示例

    以下展示所有选项的完整示例:

    favicon: /img/favicon.ico
    
    menu:
      首页: /
      归档: /archives
      标签: /tags
      分类: /categories
      友链: /links
      开往:
        url: https://www.travellings.cn/go.html
        external: true
      关于: /about
    
    dark_mode:
      enable: true
      default: light
    
    font:
      enable: true
      host: https://fonts.googleapis.com
      global:
        external: true
        families:
          - Fredoka:wght@400;500;600;700
          - Nunito:wght@300;400;500;600
          - JetBrains+Mono:wght@400;500
    
    comments:
      enable: false
      twikoo:
        envId: ''
        region: ap-shanghai
    
    footer:
      since: 2024
      author: ''
      powered: true
      social:
        travelling: true
        github: true
        email: false
        custom: []
      custom: ''
      beian:
        icp: ''
        moe: ''
        chabei: ''
    
    siteInfo:
      url: ''
      avatar: ''
      atom: ''
    
    hero:
      mode: fixed
      text: 欢迎来到我的博客
      texts:
        - 欢迎来到我的博客
        - 用文字记录思考
    
    plans: []
    
    profile:
      avatar: ''
      motto: ''
      social: []
    
    friendGroups:
      朋友们: 👋
    
    tags:
      icon: ''
    
    categories: {}
    
    friends: []
    
    siteStats:
      enable: false
      startDate: '2024-01-01'