r/webdev • • 1h ago

Question Headless cms

Sorry it maybe a stupid question but I read today about headless CMS, it being to be portable to every kind of device and it being "the new thing".

I went to read a few blogs but still don't understand its advantages.

Where is the difference when I store all content/paths in a json like I currently have?

0 Upvotes

10 comments sorted by

7

u/SPEZ_IS_A_JABRONI 1h ago

headless doesn't refer to how the data is stored it describes the relationship between the frontend and the backend. Ie, the 2 are largely independent.

1

u/ExplanationOk2014 1h ago

Thank you. I wrote it below, it seems I build my site already in that direction. Prior it was a html site but then I switched to php and put everything in i18n json files with a few slugs.

2

u/SkyTheLine 1h ago

Look, i use it and love it. Imagine, that the backend can be modified and controlled without any inteference. Mainly because i seperate it with the frontend. On the frontend site everything is static rendered. Perfext for cdn and branching. Control it, deploy it and love it. I control frontend, backend and can do branching both.

1

u/ExplanationOk2014 1h ago

Thank you. I answered already to the others users here. It seems I unintentionally built something similar and independent..

1

u/SkyTheLine 1h ago

Well, it depends. My site example has a rest endpoint and if i build an iwatch app, iphone/mac… etc. The needed data can be requested. Im also currently building it graphql, so only the requested parts are responding. You have to think with horizontal and vertical scalable architecture. When no backend activity is there, the site and microservices with the database ar shutdown. But frontend repsonds and awaken everything if needed.

2

u/MisterEd_ak php 1h ago

It just means you can focus on developing the frontend without having to also write the enitre backend system.

The CMS, like Drupal for instance, provides the JSON API and all of the required forms and content management so you can have multiple people maintaining content.

1

u/ExplanationOk2014 1h ago

Yes thank you. It seems I unintentionally built myself something like it but did not know its called headless...

I will now try to figure out what a CMS with head is..😆

2

u/Beregolas 1h ago

I mean, sure, there are a few posts about headless CMS right now, but it's certainly not "the new thing". They have been around for decades.

A CMS is a Content Management System. It has many jobs, but most of them can be boiled down to: Give the Admins an Interface to manage the data, and give the users an interface to consume it.

Many CMS come with their own frontend: WordPress is probably the best known example.

Some only offer an API and no GUI to interact with them natively: they are headless. For most use cases, you would bring your own GUI, for example by building it.

Where is the difference when I store all content/paths in a json like I currently have?

There is none. If you build a system, that stores all data as JSON and can retrieve it well enough for your users, congratilations, you have a CMS. If you don't ship a UI, you have a headless CMS.

That being said: JSON files on the backend have a myriad of issues, most of which only start coming up once you either scale, or try doing something fancy that just doesn't work well with multiple strewn JSON files. The first things that come to mind are searching and indexing, sorting and filtering, access control (is just way harder than it needs to be), reading and writing is probably slower than a DB, especially if you are doing it wrong (language dependent), etc.

As long as you don't run into any issues, and are programming for fun: JSON is completely fine. If you want to improve, try looking into more advanced backend setups, like SQL based databases, or if you want to stay in the file/document style without exactly defined schemas, try something like MongoDB.

1

u/ExplanationOk2014 1h ago

Thank you very much for your elaborate answer. Yes then I created a headless CMS without knowning that I have one. My json can be deployed anywhere and don't need a customer GUI.

I thought headless cms is some kind of new database that needs no html or whatever. 🫣

Currently i store all data in a i18n-json with 5 languages as machine translation is still awful. I can also sort, search, index it as I have a library which I built for searching my ~1000 books. I created some kind of webshop where I can choose my books and it's gives me a list where I can find it.

I can believe that for more fancy things a database is needed but I never understood how it exactly works despite me trying to figure out what primary keys and stuff is during the lockdown. Today I would most probably only vibecode it without understanding it.