main.css 在使用 jekyll 构建 github 页面网站时获得索引

main.css getting indexed when github pages site gets built with jekyll

我正在尝试设置我的网站(https://ashishrao7.github.io/ashish-rao/) using github pages and so far the experience has been good except for one small thing. An additional tile appears on the home page and the source of the problem is that the css file assets/css/main.css gets indexed as a page for some reason. I am using a modified version of the jekyll theme named Forty https://andrewbanchich.gitlab.io/forty-jekyll-theme/

我可以通过转到“_site”文件夹(不包含在回购中,因为它是构建的)并删除与那个不需要的图块关联的代码,在本地临时解决这个问题。但是,每次我重建我的网站并且我正在寻找更永久的解决方案时,它都会重新出现。经过一些调试,我发现这个不必要的索引图块由于某种原因在 _includes\tiles.html:

中被检测为 page
{% for page in site.pages limit:site.tiles-count %}

但是,我现在卡住了,我不知道如何解决这个问题。恼人的tile如下图所示

点击后,查看者将转到页面 https://ashishrao7.github.io/ashish-rao/assets/css/main.css which is not what I intended. Here is the link to the github repo that hosts the site https://github.com/ashishrao7/ashish-rao

我绝对可以重现,但这看起来是 site.pages 的预期行为。

site.pages – A list of all Pages.

来源:https://jekyllrb.com/docs/variables/#site-variables

也就是说,在列出所有 site 变量的同一页面上,您可以使用另一种方法:

site.html_files – A subset of site.static_files listing those which end in .html.

所以你只需要改变你的循环

{% for page in site.pages %}
  {{ page.title }}
{% endfor %}

{% for page in site.html_files %}
  {{ page.title }}
{% endfor %}