I’ve been mostly configuring my site on my main .toml file and so far I thought I knew I could do anything with hugo, oh was I wrong.
I need to create a single page and the theme I am using was a one-pager so I am doing it from 0 but I have ran into a small issue with the .range thingy.
In the toml if one were to have some type of a list you would define it like this:
[[params.offers.item]]
title = ""
subtitle = ""
And In code it would translate to something like this:
{{ with .Site.Params.offers }}
{{ range .item }}
{{ .title }}
{{ .description | markdownify }}
{{ end }}
Thus letting me add however many items in the toml file under the offers section.
This is exactly the same thing I want to replicate on my single page now but .md pages sadly dont have the same rules :c
In the page variables guide there is an example with the authors if you wanted to give names and so on I could use but I need the freedom of adding however many items I want.
First off you are missing a closing {{end}} tag for your with second I think you need to range .Params.offers.items and not item like you currently have, take a look at this post so you can see something similar: How can I make pairs of information in the front matter?
Okay I figured that what I am actually confused about is how can I create info pairs inside my config.toml file inside my .md-> what i presume is -> yaml file
The first one with the yaml problem I understand that I am clearly using Toml parameters thus switching to +++ I encounter a different error, an error that I am not even sure what means.
If i go by some of the docs on here I concluded that they arent needed at all, then guess what no error but nor do I see any content If i ask for it, such as the h1->Title im calling out.
Notice that what I want to achieve isnt to Access Nested Fields in Front Matter that we can find in the docs BUT its somewhat close, I need to have multiple items and for the .html to add them accordingly just like you would do in a config.toml file
In the future, post your code in text format, not screenshots. See Requesting Help to learn how to do this.
So, your first.md still has invalid front matter. You changed the --- to +++, but did not convert the remaining variables to TOML syntax. It needs to be:
+++
title = "First"
date = "2018-11-03"
draft = false
[[testitem]]
title = "A Title"
description = "A Description"
+++
Also see the hugo docs on example configuration. They show the difference between YAML/TOML/JSON.
If you plan to use TOML for your front matter going forward, you may want to update your archetype file(s) so that new posts/pages are created with TOML.