hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
38.86k stars 4.76k forks source link

Subdirectory not working properly #1775

Closed PurplePenguin4102 closed 8 years ago

PurplePenguin4102 commented 8 years ago

A freshly installed blog: http://jhray.com/blog

notice that archives guides you to http://jhray.com/archives instead of http://jhray.com/blog/archives

I set the _config.yml to `# Site title: Hexo subtitle: description: author: Joey Ray language: default timezone:

# URL ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' url: http://jhray.com/blog root: /blog/ permalink: :year/:month/:day/:title/ permalink_defaults: ` when I inspected public/index.html the href on the archive link was ser to '/' instead of '/blog/'

Xuanwo commented 8 years ago

Yes, I reproduced it both in landscape and next. It's not a theme issue, something happened to Hexo.

Xuanwo commented 8 years ago

It confused me that they look good from code:

https://github.com/hexojs/hexo/blob/ef6e15d0c8be73c42620b5fccb626d3b55094cf4/lib/plugins/helper/url_for.js#L32

https://github.com/hexojs/hexo-theme-landscape/blob/master/layout/_partial/header.ejs#L17-L19

PurplePenguin4102 commented 8 years ago

A similar thing was happening with the flexy theme. From reading url_for.js, my guess is that

if (data.protocol)

is returning false instead of true for some reason. That or options.relative isn't set.

Xuanwo commented 8 years ago

data.protocol is just to check is there http or https in url, I think not here.

Xuanwo commented 8 years ago

@PurplePenguin4102 Hello, this problem was fixed in hexo 3.2beta. You can install it by npm install hexo@beta --save

And I make a fault that: the code in github is latest, but our environment is still in 3.1.1. = =

leesei commented 8 years ago

@PurplePenguin4102 3.2beta may have other issue, that's why it's not yet pushed to npm. Use with care.

@Xuanwo You can use hexojs/hexo in package.json. But I have hexo cloned separately to be able to run test on it. https://gist.github.com/leesei/82bd16ec2edfbdbad981

PurplePenguin4102 commented 8 years ago

yeah no worries, thanks guys :) Awesome that there was already a fix :+1:

Xuanwo commented 8 years ago

@leesei OK, I got it~

RohanGautam commented 4 years ago

I still had this issue. I had to use my main github page(username.github.io) for it to work. Literally the same issue as this on hexo 4.2.0! Let me know if there's anything that can be done

muyi110 commented 3 years ago

I still had this issue. I had to use my main github page(username.github.io) for it to work. Literally the same issue as this on hexo 4.2.0! Let me know if there's anything that can be done

I had this issue too.

dimaslanjaka commented 1 year ago

Same problem here hexo@6.3.0 used for deploying to https://www.webmanajemen.com/chimeraland/

image image

dimaslanjaka commented 1 year ago

Related for hexo@6.3.0 https://github.com/hexojs/hexo/issues/5086