如何更改我的Jekyll / Github页面的主页?

时间:2017-07-11 06:04:38

标签: html jekyll github-pages jekyll-bootstrap jekyll-paginator

我是自学/全新的Jekyll和Github Pages,目前正在aweekj.github.io/Kiko-plus/上使用Kiko主题。我在更改默认配置时遇到了一些实际困难。

如您所见,当前主页显示主页标题和帖子列表。还有一个很酷的标签页面在aweekj.github.io/Kiko-plus/tags /.

如何更改Github Pages / Jekyll设置,以便显示主页标题和标记页而不是帖子列表?

实际上,我试图让它看起来像this

  • 具有主页标题,各个标记以及标记+帖子列表。

我对Jekyll / Github Pages完全陌生,所以我不知道从哪里开始+无法找到任何接近我正在使用的配置的内容。

These are the Github source files我正在使用下面的index.html。

---
layout: default
---

<header class="header">
  <div class="header-title">
    <a href="{{ site.url }}{{ site.baseurl }}">{{ site.name }}</a>
  </div>
  <nav class="header-nav">
    {% for nav in site.nav %}
    {% if nav.url contains 'http://' or nav.url contains 'https://' %}
    <a href="{{ nav.url }}">{{ nav.name }}</a>
    {% else %}
    <a href="{{ nav.url | prepend: site.baseurl }}">{{ nav.name }}</a>
    {% endif %}
    {% endfor %}
  </nav>
</header>

<div class="list">
{% if site.posts.size == 0 %}
  <h2>No post found</h2>
{% else %}
<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
  <div class="list-post">
    {% if post.link %}
    <a href="{{ post.link }}">
    {% else %}
    <a href="{{ post.url | prepend: site.baseurl }}">
    {% endif %}  
      <div class="list-post-date">
        <time>{{ post.date | date_to_string }}</time>
      </div>
      <div class="list-post-title">
        {{ post.title }}
      </div>
      {% if post.description %}
      <div class="list-post-desc">
        {{ post.description }}
      </div>
      {% endif %}
    </a>


  </div>
{% endfor %}
  <!-- Pagination links -->
  <div class="list-pagination">
    <span class="list-pagination-previous">
      {% if paginator.previous_page %}
        <a href="{{ paginator.previous_page_path | prepend: 
site.baseurl }}" class="previous">
          &#xE000; previous
        </a>
      {% else %}

      {% endif %}
    </span>

    <span class="list-pagination-next">
      {% if paginator.next_page %}
        <a href="{{ paginator.next_page_path | prepend: site.baseurl 
}}" class="next">
          next &#xE001;
        </a>
      {% else %}

      {% endif %}
    </span>

  </div>
{% endif %}
</div>

_site.css是这样的:

* {
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
}

html {
  font-family: $base-font;
  font-size: $base-font-size;
  line-height: 1.6;
}

html,
body {
  margin: 0;
  padding: 0;
}

.content-container {
  max-width: 48rem;
  padding: 5rem 1rem;
  margin-left:  auto;
  margin-right: auto;

  @media (max-width: 48rem){
    padding: 2rem 1.3rem;
  }
}


/*--------------
  Header
  -------------- */
.header {
  padding: 2%;
  margin-bottom: 1.5em;

  &-title {
    margin: 0.3em 0;
    font-size: 2.25em;
    line-height: 1.2em;
    font-weight: 600;

    a {
      color: $base-color;
      &:hover,
      &:focus {
        text-decoration: none;
      }
    }

    span {
      color: $oc-gray-5;
    }

  }

  &-nav {
    a {
      color: $oc-gray-7;
      text-transform: lowercase;
      -webkit-transition: all .2s ease;
         -moz-transition: all .2s ease;
              transition: all .2s ease;
      margin-right: .3rem;

      &:hover,
      &:focus {
        color: $oc-gray-7;
        text-decoration: none;
      }
    }
  }
}

.header-small {
  text-align: left;
  margin-bottom: .75rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;

  a {
    color: $base-color;

    &:hover,
    &:focus {
      text-decoration: none;
    }
  }
}

/*--------------
  Page
  -------------- */

.page {
  &-title {
    margin-top: 0;
    margin-bottom: 2rem;
    font-size: 2.25em;
    line-height: 1.2em;
    font-weight: 600;
  }
}


/*--------------
  Post
  -------------- */
.post {

  &-title {
    margin-top: 0rem;
    margin-bottom: 0.3rem;
    font-size: 2.25em;
    line-height: 1.2em;
    font-weight: 600;
  }

  &-date {
    margin-bottom: .5rem;
    color: $oc-gray-8;
    font-size: .75rem;
    text-transform: uppercase;
  }

   &-tag {
    margin-bottom: 1.5rem;

    ul {
      li:before {
        content: ""
      }

      li {
        margin: 0;
        font-size: .75rem;
        font-weight: 300;
        display: inline;
        list-style-type: none;
        text-transform: lowercase;

        a {
          display: inline-block;
          margin: 4px;
          margin-left: 0px;
          color: $oc-white;
          background-color: $oc-gray-6;
          text-decoration: none;
          border-radius: 3px;

          span {
            float: left;
            padding: .5px 5px;
          }
        }

        a:hover {
          background-color: $oc-gray-7;
        }

        a:visited {
          background-color: $oc-white;
        }
      }
    }
  }

  &-disqus {
    margin-top: 4rem;
  }

}

/*--------------
  Post list
  -------------- */

.list {
  &-post {
    padding: 4% 2%;

    &:hover {
      background-color: $background-over-color;
      border-color: transparent;
      border-radius: 10px;
    }

    a {
      color: $base-color;

      &:hover,
      &:focus {
        text-decoration: none;
      }
    }

    &-title {
      margin-bottom: .3rem;
      font-size : 1.8rem;
      font-weight: 600;
    }

    &-date {
      color: $base-lighten-color;
      font-size: .8rem;
      text-transform: uppercase;
    }

    &-desc {
      color: $base-color;
      margin-bottom: .25rem;
      font-size :1rem;
    }
  }

  &-pagination {
    margin-top: 4rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
    // text-transform: lowercase;

    &-previous {
      float: left;
      padding-left: 2%;
      a {
        color: $oc-gray-6;

        &:hover,
        &:focus {
          color: $oc-gray-7;
          text-decoration: none;
        }
      }
    }

    &-next {
      float: right;
      padding-right: 2%;
      a {
        color: $oc-gray-6;

        &:hover {
          color: $oc-gray-7;
          text-decoration: none;
        }
      }
    }
  }
}


/*--------------
  Tags
  -------------- */
.tag {
  &-index {
    ul {
      li:before {
        content: ""
      }

      li {
        margin: 0;
        font-size: 0.8rem;
        display: inline;
        list-style-type: none;
        text-transform: lowercase;

        a {
          display: inline-block;
          margin: 4px;
          margin-left: 0px;
          color: $oc-white;
          background-color: $oc-gray-6;
          text-decoration: none;
          border-radius: 3px;

          span {
            float: left;
            padding: .5px 5px;
          }

          .count {
            background-color: $oc-gray-7;
            border-radius: 0 3px 3px 0;
          }
        }

        a:hover {
          background-color: $oc-gray-7;
        }
      }
    }
  }

  &-title {
    font-size: 1.4rem;
    font-weight: 600;
    text-transform: lowercase;
    padding: 1rem 0;
  }

  &-post {
    a {
      color: $base-color;

      &:hover,
      &:focus {
        text-decoration: none;
      }
    }

    &:hover {
      color: $base-color;
      text-decoration: none;
      background-color: $background-over-color;
      border-color: transparent;
      }
  }
}

/*--------------
  Archive
  -------------- */
.archive {
  &-list {
    &-post {
      padding: 0.1rem;

      &:hover {
          background-color: $background-over-color;
          border-color: transparent;
      }

      a {
        color: $base-color;

        &:hover,
        &:focus {
          text-decoration: none;
        }
      }

      &-title {
        font-size : 1.2rem;
        font-weight: 400;
      }

      &-date {
        color: $base-lighten-color;
        font-size: .75rem;
        text-transform: uppercase;
      }
    }
  }
}


/*--------------
  Footer
  -------------- */
.footer {
  text-align: center;
  font-size: .75rem;

  &-link {
    margin: .2rem;

    a {
      color: $base-color;
      margin: 4px;
    }
  }
}

1 个答案:

答案 0 :(得分:0)

我最终找到了解决方案。我只需要使用tags文件夹的index.html中的代码替换在根文件夹的index.html中生成帖子列表的代码。把它放在那里,以防任何人有/将有类似的问题。谢谢!