javascript - baseurl 在 Jekyll 中不起作用

标签 javascript css jekyll

我试图在“myaccount.github.io/Templates”中创建一个 github 页面。在使用 Jekyll 时,我设置了 baseurl :/templates 但是当访问上面的链接时,JS 和 css 文件没有加载。 head.html 是这样的(包含在主页中):

<head>
  <link href="http://gmpg.org/xfn/11" rel="profile">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">

  <!-- Enable responsiveness on mobile devices-->
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

  <title>
    {% if page.title == "Home" %}
      {{ site.title }} &middot; {{ site.tagline }}
    {% else %}
      {{ page.title }} &middot; {{ site.title }}
    {% endif %}
  </title>

  <!-- CSS -->
  <link rel="stylesheet" href="{{ site.baseurl }}public/css/poole.css">
  <link rel="stylesheet" href="{{ site.baseurl }}public/css/syntax.css">
  <link rel="stylesheet" href="{{ site.baseurl }}public/css/hyde.css">
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface">

  <!-- Icons -->
  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ site.baseurl }}public/apple-touch-icon-144-precomposed.png">
                                 <link rel="shortcut icon" href="{{ site.baseurl }}public/favicon.ico">

  <!-- RSS -->
  <link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">
</head>

index.html:

---
layout: default
title: Home
---

<div class="posts">
  {% for post in paginator.posts %}
  <div class="post">
    <h1 class="post-title">
      <a href="{{ post.url }}">
        {{ post.title }}
      </a>
    </h1>

    <span class="post-date">{{ post.date | date_to_string }}</span>

    {{ post.content }}
  </div>
  {% endfor %}
</div>

<div class="pagination">
  {% if paginator.next_page %}
    <a class="pagination-item older" href="{{ site.baseurl }}page{{paginator.next_page}}">Older</a>
  {% else %}
    <span class="pagination-item older">Older</span>
  {% endif %}
  {% if paginator.previous_page %}
    {% if paginator.page == 2 %}
      <a class="pagination-item newer" href="{{ site.baseurl }}">Newer</a>
    {% else %}
      <a class="pagination-item newer" href="{{ site.baseurl }}page{{paginator.previous_page}}">Newer</a>
    {% endif %}
  {% else %}
    <span class="pagination-item newer">Newer</span>
  {% endif %}
</div>

布局:(default.html)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">

  {% include head.html %}

  <body>

    {% include sidebar.html %}

    <div class="content container">
      {{ content }}
    </div>

  </body>
</html>

我不明白为什么没有加载 css 文件!

最佳答案

如果您的网址是 myaccount.github.io/Templates,那么您的基本网址是:

baseurl: "/Templates" # Uppercase T

关于javascript - baseurl 在 Jekyll 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24474047/

相关文章:

javascript - 如何遍历 Javascript 中的嵌套对象?

html - 如何在固定宽度范围内换行或打断长文本/单词?

php - 在本地 MacOS Jekyll 站点上运行 PHP 代码,端口 4000

yaml - Jekyll 中的液体嵌套 For-Loop 语法问题

javascript - 从当前选项卡上下文打开一个新选项卡(何时关闭弹出窗口)?

javascript - IE7 中的 jQuery 隐藏/显示方法行为

javascript - 如何在点击处理程序上检查键盘修饰符,如 "shift"?

html - 使用 Firefox 查看网页时出现奇怪的中断

html - CSS:如何防止文本对布局造成严重破坏?

Jekyll Front Matter 变量未在中间布局中设置?