支持非根URL/Add support for non-base url #270
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference to static files were absolute and did not support Jekyll's
baseurl
parametre, which, if the website is deployed with a url that isnot root (e.g.
mirrors.tuna.tsinghua.edu.cn/mirrors
), a 404 will bereturned when fetching static files as they are not correctly
referenced, causing the website to display that javascript was not
supported by the browser.
对静态文件的引用是绝对的(默认其在根目录下),并且不支持Jekyll的
baseurl
参数。这样一来,如果网站被部署在非根目录下(比如mirrors.tuna.tsinghua.edu.cn/mirrors
),由于静态文件没有被正确引用,在访问它们时会导致404,网站则因此会显示浏览器不支持JS。To solve this issue, this Q&A is referenced:
我参考了这个论坛问答,
https://talk.jekyllrb.com/t/relative-url-and-baseurl/2051,
by changing
href="/static/114514.js"
to"{{ site.baseurl }}/static/114514.js"
we can eliminate the problem.
如此修改可以解决这个问题。
Nevertheless, it should be noted that there may possibly be other
static references which this single commit did not cover.
不过,这个commit不一定修复了所有的静态引用(∮ ′⌒`)