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

Zola creates a link that goes nowhere (linkchecker doesn't complain) #603

Closed
jonas-schievink opened this issue Jan 29, 2019 · 11 comments
Closed

Comments

@jonas-schievink
Copy link

Bug Report

Environment

Zola version: 0.5.1

Expected Behavior

Both links should link to the respective blog post, or both of them should be detected as invalid by the linkchecker.

Current Behavior

One of the links works fine, the other one links to a page that doesn't exist.

Step to reproduce

  • Clone this repo and run zola serve: https://github.com/jonas-schievink/zolarepro
  • Go to http://127.0.0.1:1111 - You'll see 2 posts, "Post 1" and "Post 2"
  • Click on "Post 1". It contains a link to the second post at http://127.0.0.1:1111/post/002-second, which works fine.
  • Go to "Post 2" by clicking the link. Post 2 contains a link back to the first post, but which has a wrong URL: http://127.0.0.1:1111/001-first.

The markdown in "Post 1" is [The next part](../002-second).

The markdown in "Post 2" is [previous post](../001-first).

Both should be correct, but zola seems to render only one of them wrongly?

@Keats
Copy link
Collaborator

Keats commented Jan 29, 2019

That looks like it's done by the markdown parser itself, very weird. This might be linked to #561 for some reason?

To use relative links in Zola, use the [previous post](./post/001-first/index.md) form and the links will be checked for existence as well.

@jonas-schievink
Copy link
Author

Hmm, apparently what we're doing is working fine on our staging and production environment, only a local zola serve is creating the bad link (this is just using the ../001-first syntax).

Even when I do zola build -u http://127.0.0.1:8000/, followed by cd public; python -m http.server brings up a working website, so this is purely a zola serve issue???

@Keats Keats added the bug label Jan 30, 2019
@Keats
Copy link
Collaborator

Keats commented Jan 30, 2019

Just to be clear, the link checker only checks external links (http) and internal when they start by ./. The fact they do link to different places is a bug though

@Keats
Copy link
Collaborator

Keats commented Jan 30, 2019

The links are not even touched by Zola actually. If you look at the generated HTML, they are still ../blabla.
So it is as you say, probably caused by the actix webserver in serve

@jonas-schievink
Copy link
Author

Just to be clear, the link checker only checks external links (http) and internal when they start by ./.

Interesting, why is that? Is there a way to raise an error when a link isn't getting checked by zola? I'd like to prevent dead links in all cases.

@Keats
Copy link
Collaborator

Keats commented Jan 30, 2019

Interesting, why is that? Is there a way to raise an error when a link isn't getting checked by zola? I'd like to prevent dead links in all cases.

Mostly because I didn't think of relative links and that it makes more sense imo to refer to the markdown files for links between content and that makes it clear it isn't an actual markdown feature.

@jonas-schievink
Copy link
Author

To use relative links in Zola, use the previous post form and the links will be checked for existence as well.

Indeed that seems to work - it feels wrong though, since the path doesn't start at the current directory (./). I guess this would be solved automatically if all links are checked for existence, since then I can use whatever format I want.

@pcwizz
Copy link

pcwizz commented Apr 22, 2019

Just tried to replicate this bug. I observed that the link previous/next post links are incorrect when navigated to directly. When navigated to from the root the links in both posts are rendered correctly. When when navigating from one post to to another the link is incorrect.

I suspect zola serve is failing to pass on the correct context somewhere. I'm not at all familiar with the zola code base but this is a good excuse to become more familiar. I'll have a go tracing and fixing this issue.

@pcwizz
Copy link

pcwizz commented Apr 22, 2019

The problem is essentially that zola serve does not redirect (301) links to directories to include the trailing / as many web servers do by default.

I think it is reasonable to expect this redirection behavior in zola serve as it lines up with common production environments. I will therefore prepare a PR implementing this redirection.

@Keats
Copy link
Collaborator

Keats commented Jun 6, 2019

@pcwizz is it coming along? actix-web got a 1.0 release that changed the usage a lot as well :/

@Keats
Copy link
Collaborator

Keats commented Mar 26, 2020

That seems fixed with the latest Zola that is using hyper, at least the repro repo works fine now.

@Keats Keats closed this as completed Mar 26, 2020
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