middleman / middleman-blog

Blog Engine Extension for Middleman
https://middlemanapp.com
MIT License
326 stars 179 forks source link

Image references in Markdown behave inconsistently #260

Closed ernie closed 9 months ago

ernie commented 9 years ago

Hi! As per discussion in #252, this is a quick description of an issue I just ran into.

Scenario:

I am using middleman-blog with the following config:

activate :blog do |blog|
  blog.prefix = 'blog'
  blog.sources = 'articles/{year}/{year}-{month}-{day}-{title}.html'
  blog.taglink = 'tags/{tag}.html'
  blog.layout = :article
  blog.summary_separator = /\-\-\-\s*READMORE/
  blog.default_extension = '.md'
  blog.tag_template = 'blog/tag.html'
  blog.calendar_template = 'blog/calendar.html'
  blog.paginate = true
end

I am referring to images stored alongside blog posts as outlined here, so, for instance:

![my nifty image](2015-08-13-my-nifty-article/image.png)

This works on the article page, assuming I view the article page first in the preview server. It does not work on the main blog index at source/blog/index.html.erb, however. If I access the index first, in fact, the cache will result in a non-working image reference when visiting the article page afterwards.

Changing the reference to:

![my nifty image](articles/2015/2015-08-13-my-nifty-article/image.png)

will, as expected, cause the reverse: a working image at source/blog/index.html.erb and a broken one on the article page.

As of right now, the only workaround I have found is to refer to the absolute source path:

![my nifty image](/blog/articles/2015/2015-08-13-my-nifty-article/image.png)

Per @tdreyno, the suspected cause is that "blog 'moves' the image assets along to the new article path, but images references in markdown don't point to that new location."

Thanks so much for looking into this!

aalvrz commented 7 years ago

I am experiencing something like this. I am using middleman (4.1.10) and middleman-blog (4.0.1). Was there any fix for this?

iwarner commented 7 years ago

@ernie Are you able to Create a PR for some Features that will test this issue. We can then start to look at a fix as it seems an issue still in the latest release. I personally have not used the relative images.

ernie commented 7 years ago

@iwarner I'm sorry, I've long since left the company where I was using Middleman, so this issue no longer affects me.