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

get_url: always add trailing slash unless path has extension? #2026

Closed
dannyvankooten opened this issue Nov 17, 2022 · 5 comments
Closed

get_url: always add trailing slash unless path has extension? #2026

dannyvankooten opened this issue Nov 17, 2022 · 5 comments

Comments

@dannyvankooten
Copy link

I just migrated my blog from Jekyll to Zola and after it's been great once I got the hang of it! Thank you for your great work on it.

One thing I ran into and that the docs were a tiny bit ambiguous about was the proper way to generate permalinks using the get_url Tera function.

The documentation for get_url states:

By default, assets will not have a trailing slash.

This + #85 gave me the impression that get_url('/about/) would return https://mysite.com/about/ but it was stripping the trailing slash because I wasn't using the internal linking (@/) feature.

Would it make sense to always append a trailing slash for anything that looks like a URL / directory? Eg anything that does not have a file extension?

@Keats
Copy link
Collaborator

Keats commented Nov 17, 2022

get_url has a trailing_slash parameter to select whether to add it or not. I'd prefer not do it automatically.

@dannyvankooten
Copy link
Author

@Keats It's removing it automatically in this case.

@Keats
Copy link
Collaborator

Keats commented Nov 17, 2022

even with trailing_slash=true?

@dannyvankooten
Copy link
Author

No, then it works as expected. It's just that I thought it would be a nice improvement to not strip it automatically for something that is obviously not an asset file.

Alternatively, maybe we can update the documentation to state that anything passed into get_url (that is not an internal link starting with '@/') while the 'trailing_slash' argument is omitted will have no trailing slash.

@Keats
Copy link
Collaborator

Keats commented Nov 18, 2022

We can update the documentation to remove the asset word from

By default, assets will not have a trailing slash. You can force one by passing trailing_slash=true to the get_url function.

magikstm added a commit to magikstm/zola that referenced this issue Nov 25, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Small update to the doc linked to the discussion on getzola#2026.
Keats pushed a commit that referenced this issue Nov 25, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Small update to the doc linked to the discussion on #2026.
@Keats Keats closed this as completed Jan 12, 2023
Keats pushed a commit that referenced this issue Feb 16, 2023
Small update to the doc linked to the discussion on #2026.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants