Search code examples
githubyaml

In Hugo Academic, how to fix "Error in user YAML: mapping values are not allowed". Hyperlinks problem


I'm working in Hugo Academic, and I'm trying to write following code in a blo

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 />

However, GitHub shows me back the error "Error in user YAML: mapping values are not allowed". In my head, I would like to get something like this:

Visiting professor in following universities:

I think it might be due to the hyperlinks, but I don't know how to solve it. Is there a smarter way to do this? Maybe creating subitems or so? Thanks a lot


Solution

  • From what you linked, the expected structure seems to be

    sections:
    - 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 />
    

    I used a folded block scalar for the description to avoid parsing parts of it as YAML substructure. The line breaks are optional and solely introduced for readability. I made them within the <br /> tags because those line breaks get folded into a space character.

    You could instead use a double-quoted scalar:

          description: "Visiting professor in following universities<br />\
            - June 2023: [LinKóping University](https://liu.se/en)<br />\
            - November 2019: [University of Sheffield]"
    

    Both styles allow writing it in a single line, but a line break is required after >- before the content.