我正在尝试使用我的大学提供的域与 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
它在 index.html 文件中生成的(许多)链接的一个例子是
<link rel="stylesheet" href="/foobar/assets/main.css">
This link向我解释说,这实际上是一个绝对路径,对我来说这似乎不是问题,但是 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
我的主页 URL
http://home.iitb.ac.in/~ishankjuneja/
与文件夹 public_html
相关联,所以上面的 main.css 的路径是不正确的。类似 href="assets/main.css"
效果很好,但我似乎无法输入 _config.yml
得到这个结果。
最佳答案
在配置中,您必须正确设置 baseurl:
baseurl: "~ishankjuneja"
然后使用
{{site.baseurl}}page.url
关于html - 强制在 Jekyll 中使用绝对 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52680191/