We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Import markdown files as entries from the server?

How Do I?

Thomas Boelskifte's avatar
Thomas Boelskifte
85 posts
4 years ago
Thomas Boelskifte's avatar Thomas Boelskifte

Hi all,

I’m writing a lot of ExpressionEngine related guides and content at the moment in Typora (a great markdown editor). When the content goes live (soon I hope) I have to copy/paste the body text from Typora, into a new EE entry with a markdown formatted textarea field.

This works great, but also means that any changes will have to be made in Typora first, and then copied over — even small typo corrections and such.

Is there any way I could have the markdown files on the server, and have them auto-update the entries? Exactly like Templates work, where you first create a template in EE, it’s then available on the server as a file, and any changes made to this file is reflected on the site when you save.

Does such a system exist already? If not, perhaps an add-on could be made, or it could be a feature of ExpressionEngine in the future?

I could see it working in a couple of ways:

  • A system where EE monitors a folder on the server, for example /system/user/markdown/ and any .md file you create there would create a new, closed entry in EE, with the markdown as the body of the entry. You could then add any images, categories and so on you want, and then publish when it’s ready. After that, any changes to the .md file updates the entry and thus is reflected online.

Or you could do the reverse, which I think I actually prefer:

  • A system where any new entries created in a certain channel, would also make a new .md file on the server, ready to be filled with text. After you publish, any changes you make to the .md file updates the entry in EE and thus online.

This would enable you to write your content in any editor you like, and work on your content as much as you want, having it just a click away from going online. And when online, any changes would be reflected instantly.

Because as great as the EE UI/UX has gotten (and it has gotten really great with EE 6) I think most people like to write longer entries in a real editor, if given the chance.

I’m nowhere close to being able to create an add-on myself, and I haven’t been able to find a solution that makes the above possible at the moment. So if anyone wants to take this on, I’d love to beta-test it with you, or be involved in any way. Other than that, the idea is free to run with 😊

Cheers,

Thomas

       
Tom Jaeger's avatar
Tom Jaeger
228 posts
4 years ago
Tom Jaeger's avatar Tom Jaeger

Hi Thomas,

Thanks for posing this. I don’t know of an add-on that does this currently. However it is a pretty interesting idea as a whole.

       
Thomas Boelskifte's avatar
Thomas Boelskifte
85 posts
4 years ago
Thomas Boelskifte's avatar Thomas Boelskifte

Hi Tom,

Great to hear you like the idea 👍 😄

I did a bit of research, and a quick google search for “blog posts from markdown files on server” gave lots of links to projects that might serve as inspiration or starting points. For example this Github called simply Markdown Blog looks a whole lot like what I’m after, sans the EE integration.

Quote:

> Extremely simple “static” PHP blog that renders markdown posts. No installation or database needed. > > To create a post just write a new .md file. Everything else just works. > > Note: It’s not a full blogging platform, does not currently come with any premade themes, it’s just a script and specific folder structure to load and display markdown files.

Anyways, there are lots of other projects like this, and integrating something similar into EE — which already has the “load from files to update database” functionality for Templates — might be pretty easy. Which … is easy to say, when it’s not you who has to code it, I know 😉

Cheers, Thomas

PS: The quote above doesn’t seem to render correctly, event though the markdown formatting should be correct, at least from here in Safari under macOS 11.2?

       
RK311y's avatar
RK311y
7 posts
4 years ago
RK311y's avatar RK311y

I use RStudio for compiling markdown files to either Bookdown HTML formats or BlogDown.

RStudio has packages that allow you to connect to MySQL servers.

You could try making some R code that would insert/update values in your database with the contents of your markdown file.

       
Thomas Boelskifte's avatar
Thomas Boelskifte
85 posts
4 years ago
Thomas Boelskifte's avatar Thomas Boelskifte

Hi everybody,

Great news! I’ve managed to put together a solution to my wish, of having ExpressionEngine pull content from Markdown files on the server, directly into entries, and have the site update when changes are made to those files!

See my original post at the top, for my thoughts on why this would be cool.

Here is a short reap of how it’s done:

  • We first create a directory on our server, to hold the Markdown files. We can then open them from there, in our markdown editor, and edit them all we want. When we save, the changes will be reflected on our site immediately.
  • We then create a field in ExpressionEngine, to hold the filename of the Markdown file. This way we associate each file with entries in ExpressionEngine.
  • And finally we’ll use Zero-MD to pull the Markdown from the file into our ExpressionEngine Template, as normal HTML.

While not particularly elegant, it’s working great and it’s not too difficult to set up. Of course having this functionality baked right into EE (or as an add-on) would still be pretty awesome, and I hope it will be at some point.

Anyways, I wrote a setup-guide and put it in a GitHub Wiki, because it grew too big to post here. Feel free to share your improvements and comments!

Links to setup-guide:

  • Introduction
  • Setup Guide Wiki
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.