【问题标题】:Jekyll site.baseurl lost in permalinkJekyll site.baseurl 在永久链接中丢失
【发布时间】:2015-02-03 10:45:23
【问题描述】:

我正在与 jekyll 合作制作一个小型网站。因为我们想隐藏帖子的日期,所以我使用固定链接。

在 localhost 上,index.html 显示良好,包含正确的 css。

浏览器正在从以下位置获取 css:

127.0.0.1:4000/css/styles.css

当我要发帖时,我的 css 不见了,因为浏览器正在这里寻找 css:

127.0.0.1:4000/permalink/css/styles.css

这是我的 config.yaml 的样子(我使用 // 当我需要隐藏信息时):

# Site settings
title: //
email: //•//.fr
description: > # this means to ignore newlines until "baseurl:"
  //.
baseurl: "" # the subpath of your site, e.g. /blog/
url: "http://127.0.0.1:4000" # the base hostname & protocol for your site
twitter_username: jekyllrb
github_username: jekyll

# Build settings
markdown: kramdown

relative_permalinks: true


sass:
    style: :compressed
    sass_dir: _sass

还有include/head.html:

<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
    <script src="{{ "/js/jquery.min.js" | prepend: site.baseurl }}"></script>
    <script src="{{ "/js/jquery.scrollzer.min.js" | prepend: site.baseurl }}"></script>
    <script src="{{ "/js/jquery.scrolly.min.js" | prepend: site.baseurl }}"></script>
    <script src="{{ "/js/skel.min.js" | prepend: site.baseurl }}"></script>
    <script src="{{ "/js/skel-layers.min.js" | prepend: site.baseurl }}"></script>
    <script src="{{ "/js/init.js" | prepend: site.baseurl }}"></script>
    <noscript>
      <link rel="stylesheet" href="{{ site.baseurl }}css/skel.css"/>
      <link rel="stylesheet" href="{{ site.baseurl }}css/style.css"/>
      <link rel="stylesheet" href="{{ site.baseurl }}css/style-xlarge.css"/>
    </noscript>
    <!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->

找到javascript文件没有问题,这就是为什么我认为href/src文件调用中有一些东西。

如果有人有想法,我会很高兴。

非常感谢。 朱

【问题讨论】:

    标签: html css jekyll permalinks


    【解决方案1】:

    此外,您可以将链接更改为 css

    <link rel="stylesheet" href="{{ site.baseurl }}css/skel.css"/>
    

    <link rel="stylesheet" href="{{ site.baseurl }}/css/skel.css"/>
    

    【讨论】:

      【解决方案2】:

      找到了,

      看起来我使用的 html5up.com 模板在 javascript 中有链接。

      只是在模板 init.js 中更改了这个:

      skel.init({
              reset: 'full',
              breakpoints: {
                  global: { href: '{{ site.baseurl }}/css/style.css', containers: '45em', grid: { gutters: ['2em', 0] } },
                  xlarge: { media: '(max-width: 1680px)', href: '{{ site.baseurl }}/css/style-xlarge.css' },
                  large: { media: '(max-width: 1280px)', href: '{{ site.baseurl }}/css/style-large.css', containers: '42em', grid: { gutters: ['1.5em', 0] }, viewport: { scalable: false } },
                  medium: { media: '(max-width: 1024px)', href: '{{ site.baseurl }}/css/style-medium.css', containers: '85%!' },
                  small: { media: '(max-width: 736px)', href: '{{ site.baseurl }}/css/style-small.css', containers: '90%!', grid: { gutters: ['1.25em', 0] } },
                  xsmall: { media: '(max-width: 480px)', href: '{{ site.baseurl }}/css/style-xsmall.css' }
              },
      

      并添加 YAML start 以获取 jekyll 处理的文件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-15
        • 2013-03-21
        • 2019-07-27
        • 1970-01-01
        相关资源
        最近更新 更多