Search code examples
jekyllgithub-pagesjekyll-theme

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


I am trying to setup my site (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/

I could temporarily solve this problem locally by going to '_site' folder (not included in the repo because it gets built) and deleted the code associated with the that unwanted tile. However, it would reappear every-time I rebuild my site and I was looking for a more permanent solution. Upon some debugging, I figured out that this unnecessarily indexed tile was getting detected as a page for some reason in _includes\tiles.html:

{% for page in site.pages limit:site.tiles-count %}

However, I am stuck now I don't know how to fix this issue. The annoying tile is shown in the figure below.

extra unwanted tile

Upon clicking, it takes the viewer to the page 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.


Solution

  • I can definitely reproduce, but it looks to be the expected behaviour of site.pages.

    site.pages – A list of all Pages.

    Source: https://jekyllrb.com/docs/variables/#site-variables

    This said, on the same page listing all the site variables, there is an alternative that you could use:

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

    So you just need to change your loop from

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

    to

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