2017-01-06 1 views
6

bundle exec jekyll build && bundle exec jekyll serve --watch을 실행하여 _site 폴더를 생성 한 다음 FTP를 통해 웹 서버에 업로드합니다. _site 폴더의 index.html 파일에는 올바른 사이트 URL이 아닌 "localhost"로컬 URL에 대한 링크가 포함되어있어 링크가 깨졌습니다. FTP를 사용하여 배포한다는 것은 링크의 텍스트가 실제 서버에 그대로 배포되고 사용자가 블로그 URL이 아닌 "localhost"로 리디렉션된다는 것을 의미합니다. 이 문제를 어떻게 해결할 수 있습니까? 전에도 문제가 발생하지 않았습니다. index.html 파일Jekyll 빌드가 _site (프로덕션) 파일에 'localhost'링크를 넣습니다.

발췌 : _config.yml에서

<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"> 

발췌 :

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 
+0

지킬 코드가 없으므로 디버깅하기가 어렵습니다. 모든 저장소 URL? 또는'_includes/head.html' 콘텐츠 일 수도 있습니다. –

답변

8
당신은 당신의 사이트를 구축 할 필요가

이 (로컬 서비스를 제공 할 수 없습니다) 그럼 당신은 업로드 할 수 있습니다 생성 된 파일을 서버에 전송하십시오.

$ bundle exec jekyll build 

그러면 con의 값을 사용하여 표준 링크가 생성됩니다. 모양 변수 url_config.yml에 입력하십시오. 당신이 지킬의 serve 명령을 실행하면 목표는 당신의 지킬 응용 프로그램을 디버깅하는 로컬 인스턴스를 제공하기 때문에

<link rel="canonical" href="https://wordbrewery.com/blog/"> 

, 다음 URL의 값은 localhost이 될 것입니다.

<link rel="canonical" href="http://localhost:4000/blog/"> 

아니면 지킬이 environmnet 변수 에 개발를 설정합니다 기본적으로, 당신은 환경에 따라 코드의 일부를 실행하도록 선택할 수 있도록도 더 environment 변수로 생산을 지정 :

:

$ JEKYLL_ENV=production bundle exec jekyll build 

그런 다음 코드에서 당신이 뭔가를 넣을 수 있습니다 같은 나중에이 가로 질러 보았 사람들을 위해

{% if jekyll.environment == "production" %} 
    {% include adsense.html %} 
{% endif %} 
0

자신-I는 I 동안 jekyll build ING가 바람직하지 않게 HTML 파일에 포함되지 localhost로 이끄는 동시에 보내고 다른 프로세스 jekyll serve를주었습니다.

다른 serve 프로세스를 취소하는 것이 처음으로 효과가있었습니다.

관련 문제