Content adapters for use with sanity.io

Hi folks,

I’ve been using Hugo for close to a decade now - personal websites, business websites, and the last couple of years even small e-commerce stores. Started off with hosting from GCS buckets and moved on to Cloudflare Pages.

The past couple of years I’ve been helping a non-profit build and maintain a website. As I try to focus on managing the site functionality, I try to reduce my involvement with managing content. So I started using sanity.io as a CMS for others to easily manage content. It’s straightforward for known sets of pages and works very well.

I’m now at a point where I want to generate pages dynamically based off of data in sanity, think a webstore with multiple product pages; and I’ve been delighted to learn of content-adapters, which seem to provide the functionality I need.

Question for the community - has anyone already attempted this with sanity? Looking for some prior art, some basic scaffolding to get started. I can probably figure it all out, but it would be very helpful to have something to start with.

1 Like

I don’t know, but I don’t think it should be too hard (and if it’s too hard, please let me know).

A related tip would be to configure the HTTP cache:

Which should enable good “edit on sanity” and preview in Hugo server workflow.

The trick part would be to convert their Portable Text (body object/methods) to HTML using Hugo Templates. I don’t think there is a go intepreter of portable text as of yet.

I’m sure it’s possible, but I tried a few years ago and it seemed to big of a task for me. We ended up using Astro instead (that was before Hugo’s Content Adapters) which I’m finally playing around with now.

We did use Hugo + Sanity as a proof of concept for one production site (still running it to this day).Caveat is we used a markdown plugin for sanity, so Hugo could interpret the page content… Hugo getRemote and GROQ worked very well together.

It would be even easier with Content adapters today, but using Sanity without Portable Text is a bit counter productive for our use cases.

Being curious, I did some tests myself today. Still early, but promising:

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