logo DocuPress
首页

YAML配置

通过简单的 YAML 配置,即可自定义一些页面数据,所有字段都是可选的。

YAML 配置分为全局配置和页面配置,其中全局配置会作用于所有页面,在获取 DocuPress 实例时传入全局配置参数。页面配置在 Markdown 文件顶部,使用---分隔,优先级高于全局配置。也就是说,若 Markdown 文件有配置,则优先使用 Markdown 文件配置,若没有配置,则使用全局配置,若全局配置也没有,则会使用默认配置。

全局配置

{
    name?: string; // 程序名称
    favicon?: string; // 网站图标
    description?: string; // 网站描述
    tagline?: string; // 网站标语
    keywords?: string; // 网站关键字
    author?: string; // 网站作者
    host?: string; // 网站域名
    port?: number; // 网站端口
    public?: string; // 公共资源路径
    docs?: string; // 文档路径
    operates?: {
        name: string;
        link?: string;
        blank?: boolean;
        list?: {
            name: string;
            value: string;
        }[];
    }[]; // 右上角操作
    menu?: {
        label: string;
    }; // 左侧边栏配置
    outline?: {
        label: string;
    };// 右侧边栏配置
    time?: string; // 网站创建时间
    title?: string; // 网站标题
    sidebar?: {
        text: string;
        items:{
            text: string;
            link: string;
        }[]
    }[]; // 左侧目录内容
}

示例

{
    name: "DocuPress",
    favicon: "/favicon.ico",
    description: "一个SEO友好的博客、文档及知识库管理工具",
    tagline: "代码󠇗笔󠆐墨󠅱 心若󠇗星󠆅河󠅼 创意󠇘通󠆭灵󠆙",
    keywords:
      "DocuPress、码界轩、博客、文档、SEO、博客系统、文档系统、博客框架、文档框架、博客系统框架、文档系统框架",
    author: "陈佳宝, mail@chenjiabao.com",
    host: "0.0.0.0",
    port: 3000,
    public: "/public",
    docs: "/docs",
    operates: [
      {
        name: "首页",
        link: "/",
      },
      {
        name: "lang",
        list: [
          {
            name: "zh-CN",
            value: "中文",
          },
          {
            name: "en-US",
            value: "English",
          },
        ],
      },
      {
        name: "theme",
      },
      {
        name: "github",
        link: "https://github.com/majiexuan",
        blank: true,
      },
    ],
    menu: {
      label: "菜单",
    },
    outline: {
      label: "页面导航",
    },
    time: "2025-06-01",
  }

页面配置

页面配置应该位于Markdown文件的最顶部,其前不应该含有其他内容,字段与全局配置的字段一致,该数据会与全局配置进行合并,优先使用Markdown文件配置。

---
title: "YAML配置"
sidebar:
  - text: "简介"
    items:
      - text: "什么是DocuPress?"
        link: "/what"
      - text: "快速开始"
        link: "/started"
      - text: "YAML配置"
        link: "/yaml"
  - text: "写作"
    items:
      - text: "Markdown扩展"
        link: "/markdown"
  - text: "Api参考"
    items:
      - text: "markdown-it-docu-press"
        link: "/markdown-it-docu-press"
---
提示

推荐至少配置一个 title 字段,一般情况下每个页面的标题应该是不一致的。

页面导航