惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
WordPress大学
WordPress大学
小众软件
小众软件
Cloudbric
Cloudbric
AWS News Blog
AWS News Blog
腾讯CDC
量子位
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
Jina AI
Jina AI
Attack and Defense Labs
Attack and Defense Labs
S
SegmentFault 最新的问题
Simon Willison's Weblog
Simon Willison's Weblog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
Google Online Security Blog
Google Online Security Blog
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
罗磊的独立博客
L
LINUX DO - 最新话题
博客园 - Franky
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
The Last Watchdog
The Last Watchdog
J
Java Code Geeks
AI
AI
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
Help Net Security
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
I
Intezer
S
Securelist

drew's dev blog

Hunting a production-only proxy bug in SvelteKit Artisanal Handcrafted Git Repositories Everything you need to know about Python 3.13 – JIT and GIL went up the hill How Postgres stores oversized values – let's raise a TOAST How Postgres stores data on disk – this one's a page turner Bumper Comtrade QuEST Rust Wrapper Dotfiles How long is a cucumber? 🥒 Jekyll KaTeX Block Using make and latexmk for easy LaTeX compilation Calculating the overlap of aerial photos Calculating meters per pixel from aerial photographs Proper line numbers with Jekyll Compiling zsh without root Coding cheatsheet
Custom Jekyll plugins with GitHub Pages
Drew Silcock · 2014-07-29 · via drew's dev blog

· 4 min read

So GitHub Pages is a fantastic resource for hosting your personal or organisation site on GitHub, for free. It even supports Jekyll! only thing is, it doesn’t support custom plugins because of the --safe flag that it compiles your site with. So what do you do?

Well, if you compile the site using jekyll yourself, then push the resulting compiled HTML to your GitHub Pages repository, then it works perfectly! You get your custom plugins, and you get your free GitHub Pages hosting.

So how do you organise the source and compiled code?

Some people, like Charlie Park, recommend two repos, one with the source code (e.g. github.com/username/username.github.io.raw for the website source code and github.com/username/username.github.io for the compiled HTML). I don’t particularly like this; it’s one project, it should be one repo.

Others, like Alexandre Rademaker, have two separate branches (a master for compiled HTML and a source for the Jekyll source), and change branches then copy the contents of _site into the master branch every time you want to push to your website.

I like the idea of separate branches within the same repo, but messing about with copying _site seems laborious and unnecessary. Here’s my solution:

Two branches: source and master.

Master contains compiled HTML, source contains the Jekyll source.

In the .gitignore of the source branch, you put the following:

Then, when you run jekyll build and Jekyll produces all the HTML in _site, git doesn’t recognise it. That means that we can cd into _site, and seeing as git doesn’t know the difference, we can make _site itself into its own git repository.

Assuming you’re starting off with a bog standard single branch Pages repo, you run:

1

# Make sure _site is empty before we begin

2

rm -rf _site/*

3

4

# Make new source branch

5

git checkout -b source

6

7

# Tell Jekyll to ignore this dir

8

touch .nojekyll

9

10

# Tell git to track source remote branch

11

git branch --set-upstream source origin/source

12

13

# Upload your branch to GitHub

14

git push origin source

15

16

# Locally delete the original master branch

17

git branch -D master

18

19

# Make a new git repository within _site

20

cd _site

21

git init

22

23

# Tell Jekyll to ignore this directory

24

touch .nojekyll

25

26

# Set the remote repository to push the HTML to

27

git remote add origin https://github.com/username/username.github.io

28

29

# Tell it to push to the master remote branch

30

git branch --set-upstream master origin/master

Now you’ve got your source branch set up in your root directory and master branch set up in your _site directory, ready for rapid building and deployment of your Jekyll website.

Now each time you want to build your site locally, you just need to run:

1

jekyll build

2

cd _site

3

git add .

4

git commit

5

git push origin master

and you have successfully built and deployed your website with Jekyll. Note that by default Jekyll does not copy .nojekyll over to _site where we need it, because it is a dotfile, so you need to put the following in your _config.yml:

Now, to automate this process, I wrote a small bash script to build, commit and push your site all in one command. Here is the gist of it, and this is the script:

1

#!/bin/bash

2

3

if [[ -z "$1" ]]; then

4

echo "Please enter a git commit message"

5

exit

6

fi

7

8

jekyll build && \

9

cd _site && \

10

git add . && \

11

git commit -am "$1" && \

12

git push origin master && \

13

cd .. && \

14

echo "Successfully built and pushed to GitHub."

So if I wanted to build my site locally and push it to my repository with the commit message “Latest build”, I would run:

1

jekgit.sh "Latest build"