Use markdown files as resources in Content Adapter pages

Given this folder structure

  • Content
    • Places
      • One
        Photo1.png
        Photo2.png
        Description.md
        MoreInfo.md
    • Places
      • Two
        Photo3.png
        Photo4.png
        Description.md
        MoreInfo.md

And a content adapter that produces pages for /Place/One and /Places/Two

How can I make a single page template that includes the .Content of the Adapter produced Page object and the resources in the leaf page bundle for the same url path. In my attempts .Page.Resources is always empty. (Well, it includes something called “Staler”)

Thanks for your help.

I must admit I did not get it completely

  • where’s your content adapter
  • more details on “that includes” and “.Content of adapter produced page”
    • maybe relation to your md files?

but anyhow it looks like you already have a setup that just does not do exactly what you want. Might be a good idea to follow: Requesting Help

and share your code - makes it lot easier to track it down

Thank you for your response. I created a minimal repo that shows what I’m working with. The readme describes what I’m trying to do (I’ve also added it below). I’ve played with it enough now to know that what I’m trying probably isn’t going to work. But I’m hoping for suggestion on best practices to achieve the goal with hugo.

This is a test repo for a question about the Hugo Static Site Generator

I’m trying to use a _content.gotmpl file to generate pages from an xml file.

My Problem is that not all of the info I need is in the xml. For example, I want to add tags and a content description for some of the nodes in the xml file. I can’t edit the xml file directly as the XML file is produced elsewhere. So, I add some related .MD files in the content/places/ folder. My thought is that this can work as a page bundle for the content pages that are generated from the xml.

This is not working. I guess I understand why… I’m mixing two methods of creating page and it is sort of a chicken and egg scenario.

So, I guess my question is, how should I be doing this?

PS D:\projects\temp\hugo-content-adapter> hugo env
hugo v0.127.0-74e0f3bd63c51f3c7a0f07a7c779eec9e922957e+extended windows/amd64 BuildDate=2024-06-05T10:27:59Z VendorInfo=gohugoio
GOOS=“windows”
GOARCH=“amd64”
GOVERSION=“go1.22.2”
github.com/sass/libsass=“3.6.5”
github.com/webmproject/libwebp=“v1.3.2”
PS D:\projects\temp\hugo-content-adapter>

Place your add-on data in another data file.

data/
├── places.xml
└── places_additional_data.json
data/places_additional_data.json
{
  "home": {
    "tags": [
      "foo",
      "bar"
    ]
  },
  "work": {
    "tags": [
      "baz",
      "qux"
    ]
  }
}

content/places/_content.gotmpl
{{ range site.Data.places.Document.Folder.Placemark }}
  {{ $content := dict "mediaType" "text/markdown" "value" .summary }}
  {{ $coordsArray := split .Point.coordinates "," }}
  {{ $lon := index $coordsArray 0 }}
  {{ $lat := index $coordsArray 1 }}
  {{ $elevation := index $coordsArray 2 }}
  {{ $tags := (index site.Data.places_additional_data .name ).tags }}
  {{ $params := dict "name" .name "lat" $lat "lon" $lon "elevation" $elevation "tags" $tags }}
  {{ $page := dict
    "content" $content
    "kind" "page"
    "params" $params
    "path" .name
    "title" .name
  }}
  {{ $.AddPage $page }}
{{ end }}

Interesting Idea. I like it. I was looking for how I could read data from the XML file like this. Examples are ellusive. Does this same index method work for XML. I’ll have to try it.

Thanks for the suggestion

Yes, it does.

OK. You definitely pointed me in the right direction. Thanks.

I think for my case I can ditch the content adapter all together. I’ll define page bundles for each place and then peek into the kml data file to get locations.

Like this:

{{ $folderName := "Places1" }}
{{ $placeName := "home" }}
{{ $folder := index (where .Site.Data.test.Document.Folder "name" $folderName) 0 }}
{{ debug.Dump ( index ( where $folder.Placemark "name" $placeName) 0 ).Point.coordinates}}

Sample KML

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
	<Folder>
		<name>Places1</name>
		<open>1</open>
		<Placemark>
			<name>home</name>
			<LookAt>
				<longitude>-126.3367438000934</longitude>
				<latitude>50.22476255664978</latitude>
				<altitude>0</altitude>
				<heading>35.42705455875917</heading>
				<tilt>41.41090368844717</tilt>
				<range>1762.066150215274</range>
				<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
			</LookAt>
			<styleUrl>#m_ylw-pushpin</styleUrl>
			<Point>
				<gx:drawOrder>1</gx:drawOrder>
	<coordinates>-126.3363483039566,50.22617188222286,0</coordinates>
			</Point>
		</Placemark>
		<Placemark>
			<name>work</name>
			<visibility>0</visibility>
			<LookAt>
				<longitude>-125.7237372351031</longitude>
				<latitude>49.8833713008373</latitude>
				<altitude>0</altitude>
				<heading>-66.16030558763055</heading>
				<tilt>25.77323748991006</tilt>
				<range>2453.223795630301</range>
				<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
			</LookAt>
			<styleUrl>#m_ylw-pushpin4</styleUrl>
			<Point>
				<gx:drawOrder>1</gx:drawOrder>
				<coordinates>-125.7197422049882,49.88759872356041,0</coordinates>
			</Point>
		</Placemark>
	</Folder>
    <Folder>
		<name>Places2</name>
		<open>1</open>
		<Placemark>
			<name>home</name>
			<LookAt>
				<longitude>-126.3367438000934</longitude>
				<latitude>50.22476255664978</latitude>
				<altitude>0</altitude>
				<heading>35.42705455875917</heading>
				<tilt>41.41090368844717</tilt>
				<range>1762.066150215274</range>
				<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
			</LookAt>
			<styleUrl>#m_ylw-pushpin</styleUrl>
			<Point>
				<gx:drawOrder>1</gx:drawOrder>
				<coordinates>-126.3363483039566,50.22617188222286,0</coordinates>
			</Point>
		</Placemark>
		<Placemark>
			<name>work</name>
			<visibility>0</visibility>
			<LookAt>
				<longitude>-125.7237372351031</longitude>
				<latitude>49.8833713008373</latitude>
				<altitude>0</altitude>
				<heading>-66.16030558763055</heading>
				<tilt>25.77323748991006</tilt>
				<range>2453.223795630301</range>
				<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
			</LookAt>
			<styleUrl>#m_ylw-pushpin4</styleUrl>
			<Point>
				<gx:drawOrder>1</gx:drawOrder>
				<coordinates>-125.7197422049882,49.88759872356041,0</coordinates>
			</Point>
		</Placemark>
	</Folder>
</Document>
</kml>

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