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

url_for(page.path) gives wrong path for prev&next page #3400

Closed
HigHwindEx opened this issue Dec 25, 2018 · 4 comments
Closed

url_for(page.path) gives wrong path for prev&next page #3400

HigHwindEx opened this issue Dec 25, 2018 · 4 comments

Comments

@HigHwindEx
Copy link

When I used ejs to get the url of prev&next page, I found the path given was wrong. I think it's because I set my blog in a subdirectory. (In fact it's www.example.com/blog/)
For example, my prev post lies in www.example.com/blog/post1.html. When Hexo renders post 2, url_for(page.prev.path) gives www.example.com/blog//blog/post1.html, which lead the link to 404.
Though it does work, do I have to use page.prev.path directly?

@yoshinorin
Copy link
Member

The url_for return from root path. How about relative_url ?

If you want to get absolute path, how about config.root + page.prev.path ? It will be return www.example.com/blog/post1.html

@HigHwindEx
Copy link
Author

The url_for return from root path. How about relative_url ?

If you want to get absolute path, how about config.root + page.prev.path ? It will be return www.example.com/blog/post1.html

Thanks a lot, dear YoshinoriN.

I think it will be better if Hexo solves this small problem, because the doc of Hexo recommends using function url_for(page.path).

@SukkaW
Copy link
Member

SukkaW commented Sep 18, 2019

In #3701 full_url_for helper is added to Hexo and will be released with Hexo v4. Use full_url_for helper after Hexo v4 if you need to get absolute path.

@SukkaW SukkaW added this to the v4.0.0 milestone Sep 18, 2019
@curbengh
Copy link
Contributor

curbengh commented Oct 1, 2019

Addressed by #3701

@curbengh curbengh closed this as completed Oct 1, 2019
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

4 participants