Contentful 2 Hugo


#1

I’ve created a tool to generate content-files for hugo from the Contentful CMS.

Feel free to check it out. Feature request / remarks / code / better documentation / feedback is welcome.


#2

Sorry for coming late to the party and bumping this thread. We’re using Hugo for bigger sites now and I’m curious if anyone has a good way to import Contentful content into Hugo. We have multiple content models in our Contentful space and I’d like to be able to pull them into Hugo sections with field identifiers. If anyone has any tricks or tips, I’d really appreciate it.


#3

Hi Andrew,

We’re working on something called Content Aggregator, which is a generic tool for fetching data from external data sources, converting data into suitable format using Node.js modules, and then storing the data into some kind of data storage, such as Elasticsearch or in this case, file system. Much like a combination of Logstash and AWS Lambda.

As a proof of concept we’ve written two examples, one for fetching content and images from Contentful, and one for creating markdown for Hugo. If you combine those two examples maybe it will fit your needs?

You can find the two examples here: https://bitbucket.org/aretera/contentaggregator.samples
Or read more about Content Aggregator here: https://bitbucket.org/aretera/contentaggregator/wiki/Home

It is still work in progress. Please let me know if you have any questions!

/Niclas


#4

Hi,

Now you can check out Foopipes, and especially an example Contentful2Hugo built with Foopipes.

/Niclas


#5

I wrote a dead simple node.js script.
It could work with contentful CDN.
Just create a loop for all content type and it should do the job.
Script


#6

Hi, I was wondering if there is any further advice or examples on how to generate content files for Hugo from Contentful CMS?

I’ve installed the c2h tool from @Arno (https://github.com/ArnoNuyts/contentful2hugo) but I’m getting an error and no files are written: “No such file or directory @ rb_sysopen - ./content/mysection/myfirstitem.md”.
(it is though correctly retrieving the ‘slug’ field of the first entry)

I’ve also tried the script from @mazli84 but am struggling likely due to my lack of knowledge. For the url in the script I’ve tried using: https://cdn.contentful.com/spaces/{spaceid}/entries?access_token={access_token}&content_type={content_type}
On running ‘node remotecontent.js’ the shell outputs “Start converting API to files”, but nothing else happens and no files are written.

For my particular use-case I’m hoping to use a webhook to Netlify to build + host. Also, incase relevant, there are multiple content types within my content model in Contentful.

Any advice or examples would be much appreciated. Thanks.


#7

I didn’t find any working solution/script to get contentful data into hugo *.md files and almost wrote a script myself but suddenly found working solution https://github.com/ithic/contentful-hugo.