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

在Hugo Academic中修复“Error in user YAML: mapping values are not allowed”错误

解决Hugo Academic YAML解析错误及访问经历展示优化

错误原因

你遇到的「mapping values are not allowed」错误,是因为YAML解析器把description字段里Markdown链接的括号、冒号当成了键值对的映射结构,导致解析失败。

解决方案

方案1:用YAML文本块保留Markdown格式

给description字段加上管道符|,让YAML把内容当成纯文本块,既保留换行和列表格式,又避免解析错误:

block: Accomplishments
- content:
    items:
    - certificate_url: 
      date_end: ''
      date_start: '2023-06-01'
      description: |
        Visiting professor in following universities:
        - June 2023: [LinKóping University](https://liu.se/en)
        - November 2019: [University of Sheffield](https://www.sheffield.ac.uk/)

这种方式不需要转义特殊字符,Markdown列表会被正确渲染成你想要的<ul>结构。

方案2:改用更贴合的Block结构(推荐)

如果只是展示访问教授经历,用Experience Block比Accomplishments更合适,结构更规范,也完全符合YAML语法:

block: Experience
- content:
    items:
    - company: LinKóping University
      company_url: https://liu.se/en
      date_end: ''
      date_start: '2023-06-01'
      description: Visiting professor
    - company: University of Sheffield
      company_url: https://www.sheffield.ac.uk/
      date_end: ''
      date_start: '2019-11-01'
      description: Visiting professor

每个经历作为独立条目,展示效果更清晰,也不会出现YAML解析问题。

方案3:包裹字符串避免解析冲突

如果坚持用原结构,也可以把description的内容用单引号或双引号包裹,让YAML识别为纯字符串:

block: Accomplishments
- content:
    items:
    - certificate_url: 
      date_end: ''
      date_start: '2023-06-01'
      description: 'Visiting professor in following universities<br />- June 2023: [LinKóping University](https://liu.se/en)<br />- November 2019: [University of Sheffield](https://www.sheffield.ac.uk/) <br />'

不过这种方式用<br />换行不够优雅,不如方案1的Markdown列表直观。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 11:23:16