Jekyll不会更新所有文件

时间:2019-08-23 10:24:12

标签: git jekyll

我有以下设置:

NAS with GIT Server ---> Raspberry Pi with Jekyll ---> rsync to web-server 

NAS收到Git提交后,它将登录到我的Pi并激活脚本。该脚本称为Jekyll:

#!/usr/bin/env bash    
MYDATE="$(date)"
PROJECT=website.git
REMOTE=username@username.example.com:html
NAS=username@nas.internal.example.com:333

# Log commit
logger "[GIT] Received commit in $PROJECT on $MYDATE"

# Change to git directory
cd ~/$PROJECT
if [ $? -ne 0 ]; then
        logger "[GIT] Directory ~/$PROJECT does not exist on $MYDATE"
        cd ..
        exit
fi


# Pull new version from the server
git pull origin master #ssh://$NAS/~/$PROJECT
if [ $? -eq 0 ]; then
        logger "[GIT] Successfully pulled new code from $PROJECT from NAS"
else
        logger "[GIT] Unable to pull code from $PROJECT from NAS"
        exit
fi

# Build Website
export JEKYLL_ENV=production
bundle exec jekyll build  --incremental
if [ $? -eq 0 ]; then
        logger "[GIT] Successfully built website from repository $PROJECT"
else
        logger "[GIT] Jekyll returned an error on $PROJECT"
        exit
fi

# Upload to hoster
rsync -aP -e ssh /home/username/$PROJECT/_site/ $REMOTE --delete
if [ $? -eq 0 ]; then
        logger "[GIT] Successfully synced website $PROJECT with remote host"
else
        logger "[GIT] Unable to sync folder of site $PROJECT with remote host"
        exit
fi

从我的输出到日志和控制台,就返回码而言,一切都井井有条。 Jekyll正在更新文章,但未更新链接文章的概述。

这是我最新文章的重点:

---
layout: post
title: redacted
date: 2019-08-23 10:00:00
categories: gist
post_image: /images/cpp.jpg
excerpt: redacted
---

如您所见,这不是头等大事。 /g/index.html中的概述页面应该是这样的:

<div style="padding-top: 2vh;"></div>
<div class="row">
  {% for post in site.categories.gist limit:20 %}
    <div class="col s12 m4 l4 dark-primary-color">
      <div class="card">
        <div class="card-image">
          <img src="{{ site.url }}{{ post.post_image }}">
          <span class="card-title"></span>
        </div>
        <div class="card-content default-primary-color primary-text-color">
          <p class="length-limit">{{ post.excerpt }}</p>
        </div>
        <div style="padding-left: 0.5vw;" class="default-primary-color primary-text-color">
          <a href="{{ site.url }}{{ post.url }}">Read</a>
        </div>
        <div style="padding-bottom: 2px;" class="default-primary-color"></div>
      </div>
    </div>
  {% endfor %}
</div>

我很茫然,为什么Jekyll不使用新文章更新概述。如果查看输出,您会看到它正在构建新文章,但没有更新应该的/g/index.html

这是我推送新内容时得到的输出:

remote:  * branch            master     -> FETCH_HEAD        
remote:    39dea32..4f0ada5  master     -> origin/master        
remote: Merge made by the 'recursive' strategy.        
remote:  _posts/gist/2019-08-23-articlename.md | 2 +-        
remote:  1 file changed, 1 insertion(+), 1 deletion(-)        

remote: Configuration file: /home/username/project.git/_config.yml        
remote:             Source: /home/username/project.git        
remote:        Destination: /home/username/project.git/_site        
remote:  Incremental build: enabled        
remote:       Generating...         
remote:                     done in 7.49 seconds.        
remote:  Auto-regeneration: disabled. Use --watch to enable.        
remote: Welcome to the lima-city SSH service.    

1 个答案:

答案 0 :(得分:1)

很难在这里发现问题,但是如果我理解您的设置,可能是一个时间问题:开发计算机和Raspberry之间的时间差。

要对此进行检查,您可以更改脚本并告诉jekyll发布所有帖子,甚至是带有将来日期的帖子。

更改:bundle exec jekyll build --incremental 注释incremental仅与jekyll serve一起使用。

致:bundle exec jekyll build --future

如果您的帖子出现:这是时间问题。

为避免此问题,可以在jekyll中设置时区(see timezones list)。

_config.yml

timezone: Europe/Paris

这将强制jekyll根据您的原始时区进行渲染,并相应地计算发布日期。