Linebreaks in front matter using Academic Theme

Greetings. Using the Academic theme. I would like add a line break to my “Affiliation” information, which is defined in the TOML of the config.toml file.

# Organizations/Affiliations.
#   Separate multiple entries with a comma, using the form: `[ {name="Org1", url=""}, {name="Org2", url=""} ]`.
  organizations = [ { name = "Department of Management and Entrepreneurship, W.P. Carey School of Business, Arizona State University", url = "" }]

Can anyone tell me how to introduce a line break between, say, “…Entrepreneurship,” and “W. P. Carey…”? I’ve tried
, putting the string in triple quotes and adding two blank lines, etc. No luck. I’ve also added extensions = ["hardLineBreak"] in the [Blackfriday] configuration section on config.toml.

Thank you for any help.

You tried markdown options, but is that markdown? The theme takes those values and somehow produces HTML, but you will need to check to see if it is parsed as markdown, or something else is happening.

Also, you will probably have better luck asking the theme author, as they will know how that parameter is used in the theme. :slight_smile:

Did you try \n?

   organizations = [ { name = "Department of Management and Entrepreneurship, \n W.P. Carey School of Business, Arizona State University", url = "" }]

You could try inserting html line breaks in your parameter like this:

organizations = [ { name = "Department of Management and Entrepreneurship, <br>W.P. Carey School of Business, <br>Arizona State University " }]

And then render it with safeHTML like this:

{{ with .Params.organizations }}{{ . | safeHTML }}{{ end }}

1 Like

Thank you. Quite new to Hugo overall. Can you please tell me where I would include the instruction {{ with .Params.organizations }}{{ . | safeHTML }}{{ end }} to control the rendering? Much appreciated.

Wherever .Params.organizations is used in the templates of the Academic theme.

If you use an editor like Sublime Text or Atom you can search your project’s directory and you will find it.

Chiming in, you can put {{ with .Params.organizations }}{{ . | safeHTML }}{{ end }} where it makes sense anywhere in your templates. Like, the theme had that on a bio page, but you wanted it in your footer, you can do it.

Super. Gave me what I needed. Thanks.

How did you get it working in the end? It would help to have a quick summary here, so that others can benefit. Thanks in advance @ghoetker.

For future reference and as requested, a summary of how I got this to work. My solution is specific to the Academic theme in its details, but should generalize. Also, I can only say that it works, not that it is the best way to do it.

  1. Searched in my project to find “.Params.organizations,” finding it in themes/academic/layouts/partials/widgets/about.html.

  2. Copied that file to [Root file of my project]/layouts/partials/widgets/about.html, creating the necessary directories along the way. This is the file I edited, since it will override the theme’s version.

  3. Discovered the relevant block in the file.

{{ range $.Site.Params.organizations }}
<h3 itemprop="worksFor" itemscope itemtype="http://schema.org/Organization">
  {{ with .url }}<a href="{{ . }}" target="_blank" itemprop="url" rel="noopener">{{ end }}
  <span itemprop="name">{{ .name }}</span>
  {{ if .url }}</a>{{ end }}
</h3>
{{ end }}
</div>
  1. Modified the fifth line thereof with the addition of | safteHTML. It now reads
  <span itemprop="name">{{ .name  | safeHTML }}</span>
  1. In the config.toml file, added <br> where I wanted linebreaks in the entry for organization. It now reads
# Organizations/Affiliations.
#   Separate multiple entries with a comma, using the form: `[ {name="Org1", url=""}, {name="Org2", url=""} ]`.
organizations = [ { name = "W.P. Carey School of Business <br> and <br> Julie Ann Wrigley <br>Global Institute Of Sustainability,<br> Arizona State University", url = "" }]
  1. Rebuilt my site. All worked!

Thanks to everyone for the help.

4 Likes

Thanks for the write-up!