Jekyll build 将 'localhost' 链接放入 _site(生产)文件
Jekyll build is putting 'localhost' links in _site (production) files
我 运行 bundle exec jekyll build && bundle exec jekyll serve --watch
生成 _site 文件夹,然后我们通过 FTP 上传到网络服务器。 _site 文件夹中的 index.html 文件包含指向 "localhost" 本地 URL 而不是正确站点 URL 的 link,导致损坏 link秒。使用 FTP 部署大概意味着 link 的文本将按原样部署到生产服务器,用户将被重定向到 "localhost" 而不是我们的博客 URL.我怎样才能解决这个问题?我之前没有遇到过任何问题。
摘自index.html:
<link rel="stylesheet" type="text/css" href="/blog/slick/slick.css"/>
<link rel="stylesheet" type="text/css" href="/blog/slick/slick-theme.css"/>
<link rel="stylesheet" href="/blog/css/main.css">
<link rel="canonical" href="http://localhost:4000/blog/">
<link rel="alternate" type="application/rss+xml" title="The WordBrewery Blog | Language Untapped" href="http://localhost:4000/blog/feed.xml">
摘自_config.yml:
title: "The WordBrewery Blog | Language Untapped"
description: "WordBrewery's home for aspiring polyglots. Study tips, book and app reviews, grammar and vocabulary lessons, interviews, and other language-learning resources."
baseurl: "/blog" # the subpath of your site
url: "https://wordbrewery.com" # the base hostname & protocol for your site
feed: <link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ site.url }}/feed.xml" target="_blank">
wordbrewery: "[WordBrewery](http://wordbrewery.com){:target='_blank'}"
languages-offered: "twenty"
# Jekyll settings
markdown: kramdown
permalink: /:categories/:title/
gems: [jekyll, jekyll-archives, github-pages, bundler, bourbon, neat, jekyll-seo-tag, classifier-reborn, jekyll-feed, nokogiri, jekyll-sitemap, "jekyll/figure"]
encoding: utf-8
lsi: true
timezone: America/Denver
logo: "{{ site.url }}/assets/images/logo-gold.jpg"
avatar: "{{ site.url }}/assets/images/fb-profile.jpg"
locale: "en_US"
# YAML defaults
defaults:
scope:
path: "" # an empty string here means all files in the project
values:
layout: post
title: "WordBrewery now has native-speaker audio for beginning Spanish"
author: "WordBrewery"
category: Learning
image: SpanishSpain.jpg
featured: true
sass:
sass_dir: _sass
您只需构建您的网站(而不是在本地提供服务),然后您就可以将生成的文件上传到您的服务器:
$ bundle exec jekyll build
这将生成规范的 link,其值为 _config.yml
.
中的配置变量 url
<link rel="canonical" href="https://wordbrewery.com/blog/">
如果你 运行 jekyll 的 serve
命令,那么 url 的值将是 localhost
因为它的目标是提供一个本地实例来调试你的 jekyll应用
<link rel="canonical" href="http://localhost:4000/blog/">
或者甚至更好地将 production 指定为 environment
变量,这样您就可以根据您所在的环境选择执行部分代码,默认情况下 Jekyll 设置environmnet
变量到发展:
$ JEKYLL_ENV=production bundle exec jekyll build
然后在您的代码中,您可以输入如下内容:
{% if jekyll.environment == "production" %}
{% include adsense.html %}
{% endif %}
对于像我这样后来偶然发现这个问题的人——我发现 jekyll build
ing 而我同时有另一个进程 jekyll serve
ing 导致 localhost 被不希望地包含在 html 个文件。
取消另一个 serve
流程首先对我有用。
我 运行 bundle exec jekyll build && bundle exec jekyll serve --watch
生成 _site 文件夹,然后我们通过 FTP 上传到网络服务器。 _site 文件夹中的 index.html 文件包含指向 "localhost" 本地 URL 而不是正确站点 URL 的 link,导致损坏 link秒。使用 FTP 部署大概意味着 link 的文本将按原样部署到生产服务器,用户将被重定向到 "localhost" 而不是我们的博客 URL.我怎样才能解决这个问题?我之前没有遇到过任何问题。
摘自index.html:
<link rel="stylesheet" type="text/css" href="/blog/slick/slick.css"/>
<link rel="stylesheet" type="text/css" href="/blog/slick/slick-theme.css"/>
<link rel="stylesheet" href="/blog/css/main.css">
<link rel="canonical" href="http://localhost:4000/blog/">
<link rel="alternate" type="application/rss+xml" title="The WordBrewery Blog | Language Untapped" href="http://localhost:4000/blog/feed.xml">
摘自_config.yml:
title: "The WordBrewery Blog | Language Untapped"
description: "WordBrewery's home for aspiring polyglots. Study tips, book and app reviews, grammar and vocabulary lessons, interviews, and other language-learning resources."
baseurl: "/blog" # the subpath of your site
url: "https://wordbrewery.com" # the base hostname & protocol for your site
feed: <link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ site.url }}/feed.xml" target="_blank">
wordbrewery: "[WordBrewery](http://wordbrewery.com){:target='_blank'}"
languages-offered: "twenty"
# Jekyll settings
markdown: kramdown
permalink: /:categories/:title/
gems: [jekyll, jekyll-archives, github-pages, bundler, bourbon, neat, jekyll-seo-tag, classifier-reborn, jekyll-feed, nokogiri, jekyll-sitemap, "jekyll/figure"]
encoding: utf-8
lsi: true
timezone: America/Denver
logo: "{{ site.url }}/assets/images/logo-gold.jpg"
avatar: "{{ site.url }}/assets/images/fb-profile.jpg"
locale: "en_US"
# YAML defaults
defaults:
scope:
path: "" # an empty string here means all files in the project
values:
layout: post
title: "WordBrewery now has native-speaker audio for beginning Spanish"
author: "WordBrewery"
category: Learning
image: SpanishSpain.jpg
featured: true
sass:
sass_dir: _sass
您只需构建您的网站(而不是在本地提供服务),然后您就可以将生成的文件上传到您的服务器:
$ bundle exec jekyll build
这将生成规范的 link,其值为 _config.yml
.
url
<link rel="canonical" href="https://wordbrewery.com/blog/">
如果你 运行 jekyll 的 serve
命令,那么 url 的值将是 localhost
因为它的目标是提供一个本地实例来调试你的 jekyll应用
<link rel="canonical" href="http://localhost:4000/blog/">
或者甚至更好地将 production 指定为 environment
变量,这样您就可以根据您所在的环境选择执行部分代码,默认情况下 Jekyll 设置environmnet
变量到发展:
$ JEKYLL_ENV=production bundle exec jekyll build
然后在您的代码中,您可以输入如下内容:
{% if jekyll.environment == "production" %}
{% include adsense.html %}
{% endif %}
对于像我这样后来偶然发现这个问题的人——我发现 jekyll build
ing 而我同时有另一个进程 jekyll serve
ing 导致 localhost 被不希望地包含在 html 个文件。
取消另一个 serve
流程首先对我有用。