Hi, I am an active jekyll user, checking out hugo.
I use jekyll for my small business - not a blog. I have a few different types of products. I keep info on those products in a data file. With jekyll I can build a product listing page quite easily by adding whatever basic content to a page, and then doing a loop over the product data. Everything is either in that one page or the data file.
Looking at hugo it looks like the product listing page would be a content page, I see hugo supports data files so that should be good, but as far as i can tell I cannot access the data file from the actual content page code - I need to do it from a layout? or a shortcode? is that correct? So within a content page you do not do anything directly with curly brackets? like even to get the page title or other front matter?
ok, thanks, I am trying to use a shortcode to do this but not having any luck. I can’t tell if a shortcode is not capable of doing what I want, or if it doesn’t like my yaml data file, or if I just can’t get the code correct.
I made a shortcode called core-products.html.
I call it in a content file (happens to be my main index file if that matters) by doing:
{{< core-products >}} - no need to pass in a parameter at this point.
- title: Digital Prints
icon: "digital-prints.jpg"
url: "/services/digital-prints/"
featured: core
description: "Simple quantity based pricing on Fuji Pro Luster, Glossy and Pearl papers."
- title: Canvas Gallery Wraps
icon: canvas-gallery-wraps.jpg
url: /services/canvas-gallery-wraps/
featured: core
description: Your image printed on canvas ready to hang on your wall.
All i end up with is testing. It is not even doing something twice - it is just skipping the data items all together.
I have also tried just deleting everything below the range bits and putting {{ . }} and I get nothing still, but if I delete one of the data items and remove the dash and indentation it will then give me all the pieces in one line - but then if I try to get just the title or the url it gives an error I think.
This article shows pretty much the same thing as I am trying to do: