Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local links don't work as expected #35

Open
elpraga opened this issue Oct 28, 2017 · 4 comments
Open

Local links don't work as expected #35

elpraga opened this issue Oct 28, 2017 · 4 comments

Comments

@elpraga
Copy link

elpraga commented Oct 28, 2017

I've been creating my notes in .md files, and I want them to be accessible from the outside world.
I've been using MDwiki, and it works perfectly, but I'd like to give CMS pico a try, because my home server might not be accessible form the outside on port 80 anymore.

Nevertheless, I run into an issue when using local links from the index.md to another files. If I use [detailed page](detailed_page) construction (which should work fine, because the file is in the same directory), the link fails, because it is trying to open ../sites/detailed_page, which obviously doesn't exist. I have to update the links to [detailed page](notes/detailed_page), which is very inconsistent.

Why is that? Is there a way to fix it?

P.S.
I also think that the correct construction should be [detailed page](detailed_page.md), so that it corresponds with the actual filename (as it should).

Could this be fixed?
.

@elpraga
Copy link
Author

elpraga commented Oct 28, 2017

Maybe the apache rewrite rule is at fault here?

@ArtificialOwl
Copy link
Member

If I remember correctly, there is some examples of links in the default template

@ArtificialOwl
Copy link
Member

please reopen this ticket if the last answer does not help

@PhrozenByte
Copy link
Collaborator

Pico CMS for Nextcloud v1.0.0 is arriving and I'm currently working through some old issues that can be resolved before releasing the app's first stable release. See help.nextcloud.com for more info.

This is an known issue also affecting Pico, thus I'm reopening this Issue for later consideration.

Actually there's no code dealing with paths in Markdown files in Pico, all paths (including relative paths) are taken as-is (even %base_url% is just a placeholder that is replaced by Pico's base URL before parsing Markdown). So, if you use a link like ![Cats](assets/cats.jpg), Pico will parse this to <img src="assets/cats.jpg" alt="Cats" />. After adding a appropriate base HTML attribute (e.g. <base href="{{ base_url }}" />) to the <head> of your Twig templates (e.g. themes/my_theme/index.twig), relative paths like the one shown above work just fine.

The problem is that other Markdown editors don't know anything about this and interpret paths relative to the current file. So, for example, if there's a ![Cats](assets/cats.jpg) in content/sub/page.md, what file is supposed to be included? It should be assets/cats.jpg, however, since most Markdown editors treats all paths relative to the current file, they think the path is content/sub/assets/cats.jpg. This won't work for obvious reasons, in these editors you'd need a path like ../../assets/cats.jpg, resulting in content/sub/../../assets/cats.jpg (equals assets/cats.jpg).

The same applies to any other relative URLs. Thus you should always use Pico's %base_url% placeholder to make URLs absolute. However, Markdown editors won't understand %base_url% - so that they appear broken there.

This is related to #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants