I’m moving from a Wordpress-like website to Hugo. I’ve converted my articles with a script I made from the database to Markdown files. Easy.
But the more I think about it, I really think having the articles in a database to generate markdown files is a smooth move. However, if I edit a Markdown file, it won’t edit the article in the database. So, there’s a lot to think about interchangeability.
One question that I have is how easy it is to move a markdown file to a database? That would give me a lot of flexibility.
That’s not related to Hugo. You might get a better response in a forum where your database system is on-topic. Having said that: storing an MD file in a database is no different from storing any other file there. And in many cases not A Good Idea™
It’s related to Hugo because many people are probably moving from databases to a flat-file system.
I don’t mean that I’m storing the flat files in a database. I have the content in the database. I moved those to a flat file. But for safety, I wonder how easy it would be to move the content from a MD file to a database if I discover this isn’t a good idea down the road. I just want to CMA.
I ask people in a Hugo forum this question because more than likely they’d have also had a similar issue while working with Hugo, like me.
I have helped clients generate Hugo web sites form AirTable, Notion, Postgresql etc. But always one way, clients add data to the DB and the site gets generated/updated.
Synchronisation is hard to get right. It will be time consuming to set up and likely brittle.
Can you not always edit the content in the DB?
You’re confirming what I was thinking and that likely will be what I do. I’d love to not have to mess with the DB if I can help it, though.
I don’t follow at all. What is “the content” here, if it’s not “a MD file”? What’s the difference between “a flat file” and “a MD file”? Again: Database programming is not on-topic here because it is completely unrelated to Hugo. And how you store a file inside a database depends on the database you’re using and its APIs.
In any case, I’d rather go with the Git(Hub) approach because that allows for versioning and restoring your content (flat, MD or whatever) to a certain point in time. The same might be possible with your database, but probably more cumbersome.
Take a look at FRJO’s reply to me. He understands what I’m asking. That might bring some clarity.
I understand your post. But I wonder about the reverse action (MD files to database) and especially the reason.
Do you need to store the MD files (or the content of the MD files) in the database in order to :
- have a backup ?
- edit them through a GUI ?
- be updated by an automated process using the Database ?
In my opinion, in your case, I’d rather (but it’s my opinion and I don’t know your needs) :
- extract the database to generate MD files
- use a control version system to store the MD files which allow a versioning, updates by several people managing concurrent updates…
Can you explain the needs of the reverse action (MD files to database) ?
PS : my goal is not to write that wht you want to do is silly, just to understand.
The reverse action is in case I need to return to a database-driven format in the future for whatever reason. For example, being told to start using Wordpress with a MySQL database. I wanted to make sure I had that in my pocket in case I needed it without needing to write a script to go in reverse. I was hoping to see if someone has already tried this. I presumed I could jettison the relational database when using Hugo, but I think I believe that it’s better to create the MD files from database-driven content after seeing the comments here.