Skip to content Skip to sidebar Skip to footer

What Is The Correct Way To Express A Path In Order To Get Pelican Generated Html To Link To An Image?

I'm just starting to create a blog with Pelican and wanted to link to an image. I did this by including the following line in my Markdown file: ./m</div><h2 id="solution_1">Solution 1:

</h2><div class="answer-desc"><p>First of all, <strong>by design</strong>, you should not change the contents of the <code>output</code> directly/manually.
You should put all your static contents in separate directory which is usually named as <code>images</code> or <code>paths</code>. And, then configure the path(s) in <code>pelicanconf.py</code> as:</p><pre><code id="code_4" class="hljs language-ini"><span class="hljs-comment"># ...</span><span class="hljs-attr">PATH</span> = <span class="hljs-string">STATIC_PATHS = ['images', 'files'] # add any no. of locations# ...

In that case, when Pelican is building actual page, it will look for any referenced static file in ./content/images and ./content/files locations. If cannot find there, it will emit the error message.

Now, answering to your trouble ...

By,

...src="./myImg1a.png" ...

Pelican look for this myImg1a.png file in your myBlog/content/ folder as you are mentioning ./ which is the root folder for Pelican is working on.

But, when you are referring it as

...src="/myImg1a.png" ...

Pelican eventually finds it in the html file's directory. By getting / as location, Pelican is looking for it in the same directory of your myblog/my-blog-post/index.html which is myblog/my-blog-post/. Hence, working. But not in the ideal way.

For a deeper understanding, please take a look into Pelican's documentation on this matter.

  1. Why was the folder /category/myImg1a.png/index.html being sought at all?

Pelican, here, just trying to be smart.

Post a Comment for "What Is The Correct Way To Express A Path In Order To Get Pelican Generated Html To Link To An Image?"