Cant get to grips with Hugo - Help needed

First time using Hugo and finding it a bit confusing. For my first project I am trying to develop and single page site, not a blog, just a single page with different sections/components.

The approach I’ve used is as follows:

Content structure:

Heres and example of a .md file

title: 'Heating, Gas, Plumbing.</br>Servicing & Repair.'
date: 2024-02-08T06:34:07Z
draft: true
ctaText: 'Need a quote?'
ctaLink: '#contact'

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales, nisl eu ultricies fermentum, nunc leo ultricies nunc, quis mattis leo libero vitae libero. Nulla facilisi. Nulla facilisi. 

Layout structure:

I’ve been attempting to call my partials inside my index.html using the following structure

{{ partial "hero.html" . }}

I am then unsure how I can output the content of the in the hero.html, e.g.

<section class="hero">
    <h1>{{ .Params.title }}</h1>
    {{ .Content }}

The partial is successfully called as I can hardcode html and view it, but struggling to get front matter properties and main content.

Where am I going wrong? I know I haven’t got the hang of Hugo workflow, but really do want to get to grips with it. I’ve tried looking at the docs, but find it confusing.

Thanks in advance.

project structure

├── headless/
│   ├──
│   ├──
│   └──
└──     <-- home page content
└── index.html    <-- home page template


title: headless <-- irrelevant/whatever
headless: true


{{ with site.GetPage "headless" }}
  {{ with .Resources.Get "" }}
    {{ .Content }}
  {{ end }}
{{ end }}

{{ with site.GetPage "headless" }}
  {{ with .Resources.Get "" }}
    {{ .Content }}
  {{ end }}
{{ end }}

You could obviously stuff those blocks in their own partials or shortcodes. Each block “gets” the “headless” page then “gets” the named resource then returns the resource’s content.

Try it:

git clone --single-branch -b hugo-forum-topic-48200 hugo-forum-topic-48200
cd hugo-forum-topic-48200
hugo server
1 Like

Thanks @jmooring that has helped :+1:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.