Middleman for magazine site

Hi all,
I´m new to Middleman and this forum :smile: I want to create an online magazine with Middleman so installed the blog gem and works perfectly. I just have a question about logic.

I have 50+ markdown files in my “blog” folder and in each markdown file has a paragraph of text and then an image below it and then text again and then an image (like any article layout) but lets say when I redo my site and want to remove the images would I have to then open up 50+ or more markdown files to remove the images? Or am I doing it all wrong :smiley:

I just wanted to double check I got it right before doing live…

Thanks in advance for anyone willing to help.

I’m not an expert, but still have some thoughts on this topic:

  • I would recommend to create a new liquid_tag or ruby helper function to embbed the images. The link to the image could be provided even the article yaml fontmatter. Thus, you need to change only the helper to change the apearance of the images.

  • You could use any kind of unix grep/sed/awk to remove the pictures manually. Regex on folders with your favourite editor would do the job as well.

Best,
Robert

@rriemann thanks for the quick reply and for giving me an idea on how to continue :smile: I forgot to post what my markdown files look like at the moment:

---
title: Dave
date: 2015-11-27 12:55 UTC
imageprofile: artist-dave-profile.jpg
image01: artist-dave-002.jpg
image02: artist-dave-003.jpg
tags: middleman, amazing, demo, tags
twitter: dave
---

![Alt text](artist-dave-profile.jpg)

<h2>Question 1</h2>
<p>Question 1 goes here</p>

![Alt text](artist-dave-002.jpg)
![Alt text](artist-dave-003.jpg)

<h2>Question 2</h2>
<p>Question 2 goes here</p>

I have generated 10 test markdown files like this. But since I am new to Ruby on Rails and Middleman I was not sure of other ways of doing it. But will look into helpers.

Template Solution

Regular expressions seem like overkill to me. If it is a very specific type of image, for example, full width banner, I recommend you add a new layout and include the image as needed.

Start with front matter, for example:

---
banner_image: banner.jpg
---

Then create a specific magazine.erb layout and you can do something like this:

<%= image_tag current_page.data.banner_image if current_page.data.banner_image %>

If you don’t need this image any more on all pages, just remove that line from the magazine.erb layout file.

See more on Layouts about how to apply that layout to your articles.

I often use for my posts the extension .md.erb which allows me to use erb tags in my markdown. So you would place the image_tag right over there which gives you more flexibiity. :smile: