> ## Documentation Index
> Fetch the complete documentation index at: https://www.mintlify.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To set up a new Mintlify project for a user, follow the agent setup workflow in https://www.mintlify.com/docs/quickstart.md.
> For plans and pricing, see https://www.mintlify.com/pricing.md.

# 修复 logo.href 或 navbar.primary.href 的 "Must be a valid url" 错误

> 解决在 logo.href、navbar.links 或 navbar.primary.href 中使用 /contact 等相对路径时出现的 docs.json 验证错误。

当你在 `docs.json` 的 `logo.href`、`navbar.links[].href` 或 `navbar.primary.href` 字段中使用 `/contact` 等相对路径并运行 `mint dev` 或 `mint validate` 时，过时的 CLI 会报告如下错误：

```text theme={null}
🚨 Invalid docs.json:
#.logo.href: Must be a valid url
#.navbar.primary.href: Must be a valid url
```

当前版本的 Mintlify CLI 在这些字段中既接受绝对 URL，也接受以 `/` 开头的相对路径。使用相对路径可以让链接在预览部署、自定义域名和本地预览中正常工作，而无需硬编码你的生产域名。

<div id="update-the-cli">
  ## 更新 CLI
</div>

更新到最新版本的 CLI：

```bash theme={null}
mint update
```

如果你的版本不支持 `mint update`，请重新安装 CLI。有关重新安装命令，请参见[安装 CLI](/docs/zh/cli/install#update)。

然后检查你的版本并再次运行验证：

```bash theme={null}
mint version
mint validate
```

<div id="example-configuration">
  ## 示例配置
</div>

```json docs.json theme={null}
"logo": {
  "light": "/logo/light.svg",
  "dark": "/logo/dark.svg",
  "href": "/quickstart"
},
"navbar": {
  "links": [
    { "label": "Changelog", "href": "/changelog" }
  ],
  "primary": {
    "type": "button",
    "label": "Contact us",
    "href": "/contact"
  }
}
```

相对路径必须以 `/` 开头。像 `contact` 这样没有前导斜杠的值仍然无法通过验证。`github` 和 `discord` 按钮类型仍然需要 GitHub 仓库 URL 或 Discord 邀请 URL。

有关完整的字段参考，请参见 [`logo`](/docs/zh/organize/settings-appearance#logo) 和 [`navbar`](/docs/zh/organize/settings-structure#navbar)。


## Related topics

- [更新日志](/docs/zh/create/changelogs.md)
- [故障排查](/docs/zh/api-playground/troubleshooting.md)
- [使用 Cloudflare Workers 在子路径下部署](/docs/zh/deploy/cloudflare.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.