picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.82k stars 616 forks source link

Relative file paths not working #229

Closed mattcooperwright closed 9 years ago

mattcooperwright commented 9 years ago

first up, really loving Pico. It's all working beautifully, except:

I've found an interesting problem when attempting to insert images into my markdown file. In theory I should be able to add a relative file path as in storing the images alongside my markdown files. However using htccess for nice urls means that the file is expected to be at:

domain.com/page/image.jpg

But the actual path is

domain.com/content-sample/page/image.jpg

My htccess file looks like this:

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L]

I'm hosted using webfaction so my folder structure looks like:

/myusername/webapps/pico_cms

I hope that's all clear, any suggestions would be amazing

Thanks, matt

theshka commented 9 years ago

Hi Matt, glad you're exploring Pico!

That is the correct behaviour, relative paths should not be used. All requests which are not a file or directory are routed through the index/Pico, parsed by markdown, and then output through {{content}} in your Twig template.

You could create a static folder to host your public images, and use a absolute path in your .md files (e.g. domain.com/content-sample/images/image.jpg) -- or for images in your layout, you could create a custom theme/template and use a path relative to it by appending to the twig variable {{ theme_url }}/your/image.jpg

Hope that helps!

mattcooperwright commented 9 years ago

Hey, thanks so much for the great response. I'm glad that it's not me doing something stupid!

It's a shame though because i'm currently using ftp software to mirror a local file structure onto my server and so it could have been really efficient to simply use relative file paths - especially for my less technical colleagues.

But not a problem really. thanks very much. love the PICO!

toledox82 commented 9 years ago

Hi @theshka I'm exploring PicoCMS and I created a content-static folder in same level of content, and put a image inside but is not working as I'm waiting. I need access images directly.

Thanks