API Based content

Hello !

I just discovered Hugo and was amazed by the how FAST builds are and I kinda like the philosophy as well.
Now I have never been an advocate for any specific technology, rather I like to “pick the right tool for the job”, and this is the object of this post: find the right tool for the job for a new project of mine.

The requirements are quite simple and straight-forward: being able to build a website with SEO in mind, while gathering content from multiple data sources.

The first assertion “build a website with SEO in mind” is quite what Hugo guarantees by ULTRA-MEGA-FASTLY pre-building the site in seconds ! Now, I have doubts regarding the second assertion: “using multiple data sources”. Indeed, from what I read so far it seems to me that Hugo only works “file based” by respecting its folders convention. Pages should come from the content folder using markdown + frontmatter and that’s it ?! or is there any way around actually ?

To be honest, I reduced my choices to “Hugo.js” or “Gatsby.js”. Hugo would be my preferred choice but I don’t find much thing around gathering data from external RESTful JSON APIs for example, whereas “Gatsby.js” offers it out of the box (but is of course WAY WAY WAY less performant than Hugo at build time).

So, does any of you is, by any chance, pulling ALL its content from some REST endpoints ?
I have searched this forum about “headless CMS”, “API JSON”, “REST content”… but honestly, there is not that much literature to get inspired from… The only “answer” I found was along the lines of “just create a program that will transform JSON to .md files”: that is clearly not a solution, as it would involve Creation/Read/Update/Delete mechanism with all the trouble one can get while building those transaction-based code (in essence, this would be like manage a file-oriented database just a la wordpress: total non-sense to me).

My question is then: can Hugo FETCH JSON from an REST API, and GIVEN THIS JSON => construct a website ?

Thanks A LOT for your help ! And I am really crossing fingers onn that one: I WANT TO USE HUGO PLEASE !!! ahah

3 Likes

The short answer is: You can pull in data from external resources, but you cannot currently generate pages (i.e. URLs) from external API data (you can only include that data in other pages).

There is an open issue about this, and it will eventually happen. But time is the limit.

2 Likes

Thanks for your quick reply ! really appreciated. Ok then.

So where can I follow / help with this feature ?

Because, in my point of view: whenever this happen, Hugo will be the tool of choice for quite most jobs I’d say… I see some external tools offer the ability to kinda sync their interface with a local repo (forestry.io for example) and if the feature you mention is aimed at being ready in 2018 for example, I’d rather go the Hugo + forestry.io path for a couple of month until I can upgrade. This way I will have fewer to change compared to a total rewrite from say Gatsby.js…

Follow these forums, and follow the issue queue. Search is almost always better than asking. :slight_smile: