getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
13.76k stars 956 forks source link

mismatch between zola serve and deployements #2320

Closed astrale-sharp closed 1 year ago

astrale-sharp commented 1 year ago

Bug Report

This line in the file resume.md

this will work with zola serve and the deployements <object data="../cv.pdf" type="application/pdf" width="800vh" height="140%">

this will work only with zola serve note that ./cv.pdf will also not work <object data="cv.pdf" type="application/pdf" width="800vh" height="140%">

Environment

Zola version: 0.17.2

├── config.toml
├── content
│   ├── blog
│   │   ├── equilibre_eq.md
│   │   ├── _index.md
│   │   ├── n-back.md
│   │   └── typstfmt.md
│   ├── _index.md
│   └── resume.md // here
├── package.json
├── package-lock.json
├── static
│   ├── cv.pdf
│   ├── editor.js
│   └── tweb
├── templates
│   └── shortcodes
│       ├── format_editor.html
│       ├── godot.html
│       └── yt.md
└── themes
    └── anemone
        ├── templates
        │   ├── base.html
            ....
        └── theme.toml

80 directories, 633 files

Expected Behavior

If a link works with zola serve, it should work in deployements, it seemed like the base url was not the same

Step to reproduce

Please provide the steps to reproduce the issue. If the issue is hard to reproduce, please provide a sample repository or sample that triggers the bug. https://github.com/astrale-sharp/astrale-sharp.github.io/tree/dcfaabe15837891d02f05784edf4a1421bd581d4

Keats commented 1 year ago

I'm not sure why it works in serve but you should not rely on relative links for assets. Use the get_url function like in https://github.com/getzola/zola/blob/master/docs/templates/index.html#L10 instead which will generate the correct URL

astrale-sharp commented 1 year ago

Oooooh I totally skipped that part, thanks tons!

Should I close this then?

Or should Zola maybe warn you when you use relative path?

Keats commented 1 year ago

We can't warn unless we were parsing every HTML template. Let's close it