iju*_*eja 3 html css url yaml jekyll
我正在尝试使用我的大学提供的域与 Jekyll 建立个人主页。
我无法解决的一个问题是 Jekyll 强迫我使用我认为与网页托管服务不兼容的绝对路径。
_config.yml 文件决定了 Jekyll 如何在作为主页的 index.html 文件中生成链接。_config.yml 看起来像这样...
title: Homepage | Ishank Juneja
email: ishankjuneja@gmail.com
description: >- # this means to ignore newlines until "baseurl:"
Personal homepage Beta version
baseurl: "foobar" # the subpath of your
site, e.g. /blog
url: "http://home.iitb.ac.in/~ishankjuneja" # the base hostname & protocol for your site, e.g.
http://example.com
twitter_username: ishankjuneja
github_username: ishank-juneja
# Build settings
markdown: kramdown
theme: minima
plugins:
- jekyll-feed
Run Code Online (Sandbox Code Playgroud)
它在 index.html 文件中生成的(许多)链接的一个例子是
<link rel="stylesheet" href="/foobar/assets/main.css">
Run Code Online (Sandbox Code Playgroud)
这个链接向我解释说,这实际上是一个绝对路径,对我来说这似乎不是问题,但是 Web 托管服务上的目录树看起来像,
public_html
??? 404.html
??? about
? ??? index.html
??? assets
? ??? main.css
? ??? minima-social-icons.svg
??? feed.xml
??? index.html
??? jekyll
??? update
??? 2018
??? 10
??? 04
??? test-post.html
Run Code Online (Sandbox Code Playgroud)
我的主页的 URLhttp://home.iitb.ac.in/~ishankjuneja/与文件夹相关联public_html,因此上面的 main.css 路径不正确。类似的东西href="assets/main.css"效果很好,但似乎没有什么我可以输入_config.yml来获得这个结果。
在配置中,您必须正确设置 baseurl:
baseurl: "~ishankjuneja"
Run Code Online (Sandbox Code Playgroud)
然后使用
{{site.baseurl}}page.url
Run Code Online (Sandbox Code Playgroud)