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

Some pages not found on Windows in zola serve #1169

Closed
anthonychwong opened this issue Sep 16, 2020 · 11 comments
Closed

Some pages not found on Windows in zola serve #1169

anthonychwong opened this issue Sep 16, 2020 · 11 comments
Labels
bug done in pr Already done in a PR

Comments

@anthonychwong
Copy link

Bug Report

Environment

Zola version: 0.11.0

Expected Behavior

Theme should be able to call shortcode and render properly.

Current Behavior

Given There are short codes defined in both base site and theme, referencing them in theme causes function not found error.

Building site...
-> Creating 3 pages (0 orphan), 1 sections, and processing 0 images
Error: Failed to render page 'D:/personal-site\content\notes\article\index.md'
Reason: Failed to render 'hyde/templates/page.html'
Reason: Function 'note_title' not found

(If the stacktrace of a panic is needed, where to add the RUST_BACKTRACE=1?)

Step to reproduce

  1. Define a shortcode in theme, e.g. <site root>\themes\<theme name>\templates\shortcodes\note_title.html
  2. Call it from theme's template
  3. zola serve failed with error Function `note_title` not found.
@Keats
Copy link
Collaborator

Keats commented Sep 16, 2020

Can you test with 0.12?

@anthonychwong
Copy link
Author

The problem still exists.

@Keats Keats added bug and removed bug labels Sep 16, 2020
@Keats
Copy link
Collaborator

Keats commented Sep 16, 2020

Ah wait, you're calling a shortcode in a template, that's not what shortcodes are for. They can only called inside a .md content file. What you are looking for are most likely https://tera.netlify.app/docs/#macros

@anthonychwong
Copy link
Author

I have tried to use macros but not working and shows Not Found

image

Step to reproduce

  1. Create file macros.html to hold all the macros
    image

  2. Import and call it somewhere in theme

{% import "macros.html" as macros %}
{% extends "index.html" %}

{% block content %}
<div class="post">
  {{ macros::note_header() }}
...
  1. Run zola serve which said render successfully and serving pages

  2. Open the page and get the error

@Keats
Copy link
Collaborator

Keats commented Sep 16, 2020

This is the server 404, nothing to do with macros. Is your repo on GH so I can take a look?

@anthonychwong
Copy link
Author

This is the site with content stripped away https://github.com/anthonychwong/getzola-issue-1169 .

@Keats
Copy link
Collaborator

Keats commented Sep 18, 2020

http://127.0.0.1:1111/notes/dummy-note-1/ works for me, are you on Windows by any chance?

@anthonychwong
Copy link
Author

Yes, that was on Windows, and I have just tried with docker image balthek/zola:0.12.0 and it works.

@Keats
Copy link
Collaborator

Keats commented Sep 20, 2020

yeah, sounds like a Windows-only issue :(
Hopefully someone on that platform can debug it.

@Keats Keats added the bug label Sep 20, 2020
@Keats Keats changed the title Shortcode not working in theme Some pages not found on Windows Sep 20, 2020
@Keats Keats changed the title Some pages not found on Windows Some pages not found on Windows in zola serve Sep 20, 2020
@udoprog
Copy link
Contributor

udoprog commented Sep 20, 2020

Here's a 3 file repro, the issue is that nested paths are not served by zola serve on 12:

Repo: https://github.com/udoprog/zola-not-serving

Zola 11:

$> scoop reset zola@0.11.0
Resetting zola (0.11.0).
Linking ~\scoop\apps\zola\current => ~\scoop\apps\zola\0.11.0
Creating shim for 'zola'.
$> zola serve
Building site...
-> Creating 1 pages (1 orphan), 0 sections, and processing 0 images
Done in 16ms.

Listening for changes in D:\repo\broken-site\{content, config.toml, templates}
Press Ctrl+C to stop

Web server is available at http://127.0.0.1:1111
$> curl http://127.0.0.1:1111/posts/post1/
StatusCode        : 200
// trimmed

Zola 12

$> scoop reset zola@0.12.0
Resetting zola (0.12.0).
Linking ~\scoop\apps\zola\current => ~\scoop\apps\zola\0.12.0
Creating shim for 'zola'.
$> zola serve
Building site...
-> Creating 1 pages (1 orphan), 0 sections, and processing 0 images
Done in 10ms.

Listening for changes in D:\repo\broken-site{config.toml, content, templates}
Press Ctrl+C to stop

Web server is available at http://127.0.0.1:1111
$> curl http://127.0.0.1:1111/posts/post1/
curl : Not Found
At line:1 char:1
+ curl http://127.0.0.1:1111/posts/post1/
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Note: curl is just a silly powershell alias.

udoprog added a commit to rune-rs/zola that referenced this issue Sep 20, 2020
…zola#1169)

This introduces `relative-path`, a crate I've written for the specific
purpose of providing platform-neutral operations over paths the same way
they are used in URLs.

This means that `///hello///` == `/hello`, which should do the same as
the existing stripping minus the platform-specific path separators
causing the [bug being referenced](getzola#1169).
udoprog added a commit to rune-rs/zola that referenced this issue Sep 20, 2020
…zola#1169)

This introduces `relative-path`, a crate I've written for the specific
purpose of providing platform-neutral operations over paths the same way
they are used in URLs.

This means that `///hello///` == `/hello`, which should do the same as
the existing stripping minus the platform-specific path separators
causing the [bug being referenced](getzola#1169).
@udoprog
Copy link
Contributor

udoprog commented Sep 20, 2020

Note: the root cause is that serving in-memory files from SITE_CONTENT uses platform-specific separators. Forward slashes on unix, backwards slash on Windows. This works nicely on unix-like systems because it matches URL path separators, but not so much on Windows.

Keats pushed a commit that referenced this issue Sep 21, 2020
…) (#1175)

This introduces `relative-path`, a crate I've written for the specific
purpose of providing platform-neutral operations over paths the same way
they are used in URLs.

This means that `///hello///` == `/hello`, which should do the same as
the existing stripping minus the platform-specific path separators
causing the [bug being referenced](#1169).
@Keats Keats added the done in pr Already done in a PR label Sep 21, 2020
@Keats Keats closed this as completed in f9ae897 Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug done in pr Already done in a PR
Projects
None yet
Development

No branches or pull requests

3 participants