picocms / Pico

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

How to link to local image (same directory as document) #645

Closed myicq closed 1 year ago

myicq commented 1 year ago

Making feets we on PICO. Looks great !

For a project, I would like to store images in same directory as the document, not in assets folder. So that I have

content
  |--- index.md
  |--- myimage.png

What is the correct way to link the image ? I tried ![title](myimage.png) and ![title](./myimage.png) which both failed.

Documentation could perhaps mention how as well, instead of assuming use of assets to be the only way ?

myicq commented 1 year ago

https://github.com/picocms/Pico/pull/368#issuecomment-243231769

missed that one. Sorry. But I still wish there was a better way of organizing things together, especially since my images are named with a random 32 char filename.

Still same case after nearly 8 years ?

PhrozenByte commented 1 year ago

Still same case after nearly 8 years ?

Yes, because it's no engineering problem. There are some rather obscure solutions utilizing URL rewriting (just search here on GitHub, it's somewhere), but in the end, all CMS (e.g. Wordpress) separate contents and assets.

Starting with Pico 3.0 (currently in dev, but you might simply give it a try...) things got a bit easier due to the new %page_path% placeholder:

As a convinience feature, you can now use the %page_id%, %page_url%, and %page_path% placeholders in your Markdown files. They will be replaced by the current page's ID (e.g. sub/index for content/sub/index.md, sub/page for content/sub/page.md, …), its URL (sub resp. sub/page in our examples), or its directory path (sub in both examples) respectively. This is useful for e.g. asset management: You can now put assets for pages in the content/sub/ directory in the assets/sub/ directory, and reference them using %assets_url%/%page_path%/my_asset.png.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: