Search code examples
galleryhugonetlifynetlify-cms

Using Netlify CMS with Hugo - creating content of Academic Hugo theme


I'm trying to integrate Netlify CMS to Academic Hugo theme. I want to build a config.yml with a collection for post, talks and so on. My question is similar to this one. I was able to configure some of the fields of each post but I was not able to include variables enclosed in []:

+++
title = "Academic: the website designer for Hugo"

date = 2016-04-20T00:00:00
lastmod = 2018-01-13T00:00:00
draft = false

tags = ["academic"]
summary = "Create a beautifully simple website or blog in under 10 minutes."

[header]
image = "headers/getting-started.png"
caption = "Image credit: [**Academic**](https://github.com/gcushen/hugo- 
academic/)"

[[gallery_item]]
album = "1"
image = "https://raw.githubusercontent.com/gcushen/hugo- 
academic/master/images/theme-default.png"
caption = "Default"

+++

Please, any config.yml can output this kind of md?

Thanks a lot for your help!

UPDATED:

At the end I was able to do it and this is other case where I had issues:

+++
# About/Biography widget.
widget = "about"
active = true
date = 2016-04-20T00:00:00

# Order that this section will appear in.
weight = 5

# List your academic interests.
[interests]
  interests = [
    "Artificial Intelligence",
    "Computational Linguistics",
    "Information Retrieval"
  ]

# List your qualifications (such as academic degrees).
[[education.courses]]
  course = "PhD in Artificial Intelligence"
  institution = "Stanford University"
  year = 2012

[[education.courses]]
  course = "MEng in Artificial Intelligence"
  institution = "Massachusetts Institute of Technology"
  year = 2009

[[education.courses]]
  course = "BSc in Artificial Intelligence"
  institution = "Massachusetts Institute of Technology"
  year = 2008

+++

Here the solution if it could help someone:

- file: "content/home/about.md"
        label: "About"
        name: "about"
        fields:
          - {label: "Widget (Don't modify)", name: "widget", widget: "string", default: "about"}
          - {label: "Active", name: "active", widget: "boolean", default: true }
          - {label: "Date", name: "date", widget: "datetime" }
          - {label: "Weight", name: weight,  default: 5}
          - {label: "Interests", name: interests, widget: object, fields: [
              {label: "Interests list", name: "interests", widget: "list", 
              default: ["Artificial Intelligence"]}]}
          - {label: "Education", name: "education", widget: "object", fields: [
              {label: "courses", name: "courses", widget: "list", fields: [
                {label: Course, name: course , widget: string},
                {label: Institution, name: institution, widget: string},
                {label: Year, name: year, default: 2010}]}]}
          - { label: "Body", name: "body", widget: "markdown", required: false }

Thanks a lot!


Solution

  • For nested fields, you will use either the list or object widgets.

    For "header", you would use the Netlify CMS object widget, and for "gallery_item" you would use the list widget.

    Example:

    - label: "Header Settings"
      name: "header"
      widget: "object"
      fields:
        - {label: "Image", name: "image", widget: "image"}
        - {label: "Caption", name: "caption", widget: "markdown"}