1

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

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

如何更改 Github Pages / Jekyll 设置,使其显示主页标题和标签页面而不是帖子列表?

实际上,我正试图让它看起来像这样

  • 具有主页标题、单个标签和标签 + 帖子列表。

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

这些是我在下面的 index.html 中使用的 Github 源文件。

---
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;
    }
  }
}
4

1 回答 1

0

我最终找到了解决方案。我只需index.html要用我想显示的页面更新文件。

在我的场景中,我将生成帖子列表的代码替换为我index.html的代码tags.html

把它放在那里,以防有人遇到/将会遇到类似的问题。谢谢!

于 2017-07-11T23:45:38.133 回答