Hexo 預設主題的 Header 連結404

裝好 Hexo 部屬到 GitHub 以後,如果你的 GitHub Pages 是用 Project Site ,幫 Repo 開一個 Pages 的話,會發現 Header中這些連結都怪怪的。
像是標題和 Home 會連結到 /,而不是 /projectname/
Archives 和訂閱會連到 /archives 和 /atom.xml 而不是 /projectname/archives 和 /projectname/atom.xml
跟你的網誌實際位置不一樣就出現404了Orz
結果是因為沒去修改預設主題的_config.yml ,位置在 theme/landscape/_config.yml# Header
menu:
Home: /projectname/
Archives: /projectname/archives
rss: /projectname/atom.xml
# Content
excerpt_link: Read More
fancybox: true
# Sidebar
sidebar: right
widgets:
- category
- tag
- tagcloud
- archive
- recent_posts
# Miscellaneous
google_analytics:
favicon: /projectname/favicon.png
twitter:
google_plus:
fb_admins:
fb_app_id:
打開_config.yml 把所有路徑都加上/projectname,這樣大致上連結就正常了。
除了你的 Logo 連結…
這東西_config.yml 裡沒得設定,還是連到/啊…
後來去 Google了 一下有人說是預設主題 landscape 有一些 Bug。
可以修改 blog/themes/landscape/layout/_partial/header.ejs 來解決,不過我不會用EJS,所以直接看了一下程式碼:<header id="header">
<div id="banner"></div>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
<h1 id="logo-wrap">
<a href="<%- url_for() %>" id="logo"><%= config.title %></a>
</h1>
<% if (theme.subtitle){ %>
<h2 id="subtitle-wrap">
<a href="<%- url_for() %>" id="subtitle"><%= theme.subtitle %></a>
把第6行的 href="<%- url_for() %>" 直接改成 href="/projectname/" 就可以正確連到首頁了。
變成這樣:<header id="header">
<div id="banner"></div>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
<h1 id="logo-wrap">
<a href="/projectname/" id="logo"><%= config.title %></a>
</h1>
<% if (theme.subtitle){ %>
<h2 id="subtitle-wrap">
<a href="<%- url_for() %>" id="subtitle"><%= theme.subtitle %></a>
之後應該會換別的主題用用看,就先將就吧。
