配置Jekyll for github PROJECT页面 [英] Configuring Jekyll for github PROJECT pages
问题描述
我设法做到了这些并为我的文件创建了模板。我甚至设法使用HAML和SASS(它们仍然都转换为html / css,这就是我推到回购站所以没有问题)。我只是认为我正在配置我的jekyll错误。首先,在其他人的页面中,没有看到在config.yml上使用baseurl或url的任何配置。
我的问题是循环访问我的帖子:
{%for site in site.posts%}
< a href ={{post.url}} > {{post.title}}< / a>
{%endfor%}
它总是生成href作为 href =/ post-title
我的 _config.yml
这:
永久链接:/ Exercises /:title
当我点击链接时,这个问题总是指向 http://corroded.github.com/exercises/title-here 当它实际上应该是 http://corroded.github.com/projectname/exercises/title-here
我实际上已经尝试过硬编码路径通过这样做:
< a href =http://corroded.github.com {{post.url}}>
并且这个工作。它转到后,但它显示为纯文本,而不是生成的HTML。我知道我在这里错过了一些非常简单的事情,但我似乎无法找到它,而我整个周末都一直在摔跤。
哦,我忘了补充一点:在我的本地主机中执行此操作,我可以访问所有内容:
http:// localhost:4000 /
,然后点击链接将会使我得到 http:// localhost:4000 / Exercises / title-here
和IT WORKS。所以我有一个相当不错的猜测,即它与配置有关。
当你在前面有斜线时你的永久链接,这意味着所有的URL应该是相对于网站的根。这就是它要 http://腐蚀的原因。 github.com/projectname/exercises/title-here
。
永久链接:练习/:title
pre>
对于使用HTML创建的任何URL,也是如此。如果您有以下情况:
< a href =/ about>
它总是会到达域的根目录(例如
http:/ /corroded.github.com/about
)。如果您的项目名称为projectname,则可以使用HTML,如< a href =/ projectname / about >
直接链接到页面(例如
http://corroded.github。 COM /项目名称/约
)。
当然,您也可以使用相对URL a>(即没有前导斜杠的URL)。你只需要知道你在目录树中的位置。
I am at my wits end here. I've been trying to look at all other example github project pages I could find and even the blogs but none exhibit the problems I am getting. First, I am trying to create a project page for my repo. I did this by following the usual tutorials, creating a gh-pages branch in my project repo and pushing.
I managed to do these and template my files. I even managed to use HAML and SASS(they still both get converted to html/css and that's what I push to the repo so no problem there). I just think that I am configuring my jekyll wrong. First, I don't see any configurations in other people's pages that use baseurl or url on config.yml.
The problem with mine is when looping through my posts:
{% for post in site.posts %} <a href="{{ post.url }}">{{ post.title }}</a> {% endfor %}
It always generates the href as
href="/post-title"
my
_config.yml
btw only has this:permalink: /exercises/:title
The problem with this when I click the link, it always points to http://corroded.github.com/exercises/title-here when it should actually be http://corroded.github.com/projectname/exercises/title-here
I have actually tried hard coding the path by doing:
<a href="http://corroded.github.com{{ post.url }}">
and this works. It goes to the post BUT it shows it as plain text and not as the generated html. I know I am missing something very simple here but I can't seem to find it and I've been wrestling with this the whole weekend.Oh and I forgot to add: doing this in my localhost, I can access everything at:
http://localhost:4000/
and clicking on links will get me tohttp://localhost:4000/exercises/title-here
and IT WORKS. So I have a pretty good guess that it has something to do with the configuration.解决方案When you have a slash at the front of your permalink, it means that all URLs should be relative to the site root. This is the reason that it's going to
http://corroded.github.com/exercises/title-here
instead ofhttp://corroded.github.com/projectname/exercises/title-here
. Try it without the first slash:permalink: exercises/:title
The same thing goes for any URLs you create with HTML. If you have:
<a href="/about">
it will always go to the root of the domain (e.g.
http://corroded.github.com/about
). If you're project is called 'projectname', you can use HTML like<a href="/projectname/about">
to link directly to pages (e.g.
http://corroded.github.com/projectname/about
).Of course, you can also use relative URLs (i.e. URLs without a leading slash) as well. You just have to be aware of where you are in the directory tree.
这篇关于配置Jekyll for github PROJECT页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!