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

absolute_url not working with empty url #5625

Closed
buckle2000 opened this issue Dec 3, 2016 · 8 comments
Closed

absolute_url not working with empty url #5625

buckle2000 opened this issue Dec 3, 2016 · 8 comments

Comments

@buckle2000
Copy link

buckle2000 commented Dec 3, 2016

{{ page.permalink | absolute_url }} will not work if page.permalink is `` (i.e. index page).

@buckle2000 buckle2000 changed the title absolute_url not working on local absolute_url not working on localhost Dec 3, 2016
@buckle2000
Copy link
Author

buckle2000 commented Dec 3, 2016

I found the cause.

return if input.nil?

Why is this the default behavior?

@buckle2000 buckle2000 changed the title absolute_url not working on localhost absolute_url not working with empty url Dec 3, 2016
@ashmaroli
Copy link
Member

absolute_url is designed to prepend <site.url>/<site.baseurl>/ to <non-empty_input>
If your site.url, site.baseurl and input are empty, then the filter returns an empty string.

@buckle2000
Copy link
Author

I think absolute_url should transform any URL-like string into a complete URL. For example, HTTPS://google.com should remain unchanged.

In the current version, this processor will only append something in front of input. This is not absolute at all.

@ashmaroli
Copy link
Member

what is the expected complete url string in your case?

@ashmaroli
Copy link
Member

if your site is configured as

url: http://www.example.com
baseurl: /blog

then for given path assets/css/style.css

absolute_url = http://www.example.com/blog/assets/css/style.css
relative_url = /blog/assets/css/style.css

and for the index-page its:

absolute_url = http://www.example.com/blog
relative_url = /blog

@ashmaroli
Copy link
Member

ashmaroli commented Dec 3, 2016

or you could define index-page url as simply /
then

absolute_url = http://www.example.com/blog/
relative_url = /blog/

@o0nj
Copy link

o0nj commented Dec 3, 2016

I have tried to reproduce the issue. Calling page.url instead of page.permalink seems to deliver the expected result:

{{ page.url | absolute_url }}

Does that work for your use case?

@buckle2000
Copy link
Author

That is useful!
Thanks.

@jekyll jekyll locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants