跳转到主要内容
你可以为整个站点设置自定义字体,或分别为标题和正文设置不同的字体。可使用 Google Fonts、本地字体文件,或外部托管的字体。默认字体因主题而异。 字体由 docs.json 中的 fonts 属性 控制。

Google Fonts

当你在 docs.json 中指定字体族名称时,Mintlify 会自动加载 Google Fonts
docs.json
"fonts": {
  "family": "Inter"
}

本地字体

要使用本地字体,请将字体文件放在项目目录中,并在 docs.json 配置中进行引用。

设置本地字体

1

将字体文件添加到项目

例如,创建一个 fonts 目录并添加字体文件:
your-project/
├── fonts/
│   ├── InterDisplay-Regular.woff2
│   └── InterDisplay-Bold.woff2
├── docs.json
└── ...
2

在 docs.json 中配置字体

从项目根目录使用相对路径引用本地字体:
docs.json
{
  "fonts": {
    "family": "InterDisplay",
    "source": "/fonts/InterDisplay-Regular.woff2",
    "format": "woff2",
    "weight": 400
  }
}

标题与正文字体的本地字体

在你的 docs.json 中分别为标题和正文配置本地字体:
docs.json
{
  "fonts": {
    "heading": {
      "family": "InterDisplay",
      "source": "/fonts/InterDisplay-Bold.woff2",
      "format": "woff2",
      "weight": 700
    },
    "body": {
      "family": "InterDisplay",
      "source": "/fonts/InterDisplay-Regular.woff2",
      "format": "woff2",
      "weight": 400
    }
  }
}

外部托管字体

docs.json 中通过引用字体源的 URL 来使用外部托管的字体:
docs.json
{
  "fonts": {
    "family": "Hubot Sans",
    "source": "https://mintlify-assets.b-cdn.net/fonts/Hubot-Sans.woff2",
    "format": "woff2",
    "weight": 400
  }
}

字体配置参考

fonts
object
文档站点的字体配置。