r/learnwebdev • u/1sockwonder • Feb 20 '20
CMS, how do you guys create one?
Hey guys/girls...I was thinking, you see a lot of tutorials on HTML/CSS, JavaScript etc but what about a custom CMS? How do you guys create a custom CMS? I have used WordPress but sometimes I think it's too much for something simple like updating portfolio site/blog.
4
u/Hookless123 Feb 20 '20
For the backend, you use a data store, a web API (REST/GraphQL) , and something for authentication and authorisation. I recommend PostgreSQL as the data store. With PostgreSQL, a GraphQL API can be created automatically with Hasura. There are various identity as a service such as Auth0 and Okta, or you can self-host an open-source identity service such as Keycloak.
For the frontend, I recommend React simply for its popularity and its ecosystem. But the best part is using a framework called React-Admin to hook up to your backend with its GraphQL data provider. React-Admin does like 80% of the work for you out of the box, almost.
Now you have a CMS but you need something to present the data to the user, for example a blog site. What you can do is create that by using a static site generator like GatsbyJS and fetch the data from your GraphQL API.
1
2
u/wischichr Feb 21 '20
Honest answer: If you don't know where to start you probably shouldn't write a custom CMS as your next project. Try different existing open-source ones instead of writing a crap one yourself.
Get comfortable with it. Try to extend it with plugins, themes, etc.
1
6
u/August-R-Garcia Feb 20 '20
Pick a web development framework, probably. Ex: Laravel, Ruby on Rails, etcetera.
Create a "posts" table (or "content," "articles," etcetera) in the database
Create Create, Read, Update, and Delete (CRUD) functionality/routes/URLs/forms to create, display, update/edit, and delete the posts table in the DB.
Create. Build a form at a URL like website.com/create-post. Form submits to a URL that takes the POST data and puts it in the DB.
Read. Create a set of URLs like website.com/posts/[post-id] that use a server-side scripting language to load DB information for that row into an HTML/PHP/other template.
Update. Build a form that displays at a URL like website.com/update-posts/[post-id] that submits to a URL that takes the POST data and updates the DB.
Delete. Build a form that displays at a URL like website.com/delete-posts/[post-id] that submits to a URL that confirms the request and updates the DB.