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

推荐订阅源

N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
WordPress大学
WordPress大学
小众软件
小众软件
IT之家
IT之家
腾讯CDC
月光博客
月光博客
量子位
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Home on Alex Plescan

bigdraw: I made a collaborative drawing site Just for fun: animating a mosaic of 90s GIFs Two computers, one monitor, zero fiddling Placeholder names should be bad and unique Rebuilding this site Okay, I really like WezTerm GNU Parallel, where have you been all my life? Timeseries with PostgreSQL Easy SVG sparklines Using Declarative Shadow DOM to embed HTML emails on a web page Selling SaaS on Gumroad PDF: The Conjoined Triangles of Success Deploying Metabase to Fly.io The ".x" Files Xcode 8 managed signing: adding new device UUIDs to a provisioning profile Emojify your Wi-Fi (Netgear R6300 edition) How to use the San Francisco Mono typeface before macOS Sierra is released Disabling App Transport Security in your development environment Swift: A nicer way to tell if your app is running in Debug mode Setting up SwiftLint on Travis CI
Development environment config overrides in Jekyll
2016-03-28 · via Home on Alex Plescan
Alex Plescan

While building this website using Jekyll I found that there were a few places where I needed to override config variables when the site is running in a development environment. Some examples of dev only overrides I wanted to do are:

  • Skip minifying the SASS output so it’s easily debuggable
  • Show all draft posts by default
  • Run the server on port 4000, accepting all incoming connections

The best way I found to do this was by having two config files; a base config used in production (_config.yml), and an override config used only in development (_config_dev.yml):

# _config.yml - Base config used in production

sass:
  style: compressed

show_drafts: false
# _config_dev.yml - Dev environment configs and overrides

show_drafts: true

# Accepts connections on port 4000 from any source
host: 0.0.0.0
port: 4000

# Don't compress SASS output
sass:
  style: full

As you can see, any dev-specific config options just need to go into the _config_dev.yml file. This can be a Jekyll option you need to override, or an option for any of your Jekyll plugins.

To launch the Jekyll server in a dev environment I then run the following command

  • note that _config_dev.yml must be specified last so that its config items override _config.yml.
$ jekyll serve --config "_config.yml,_config_dev.yml"

This command will first load in the normal config, and then the dev only overrides. To make this even easier to launch I put the command under a script/dev file so I can launch it without having to type out the names of both the config files. You can see an example of this in my repo for this website.

Since I’m deploying this using GitHub pages I didn’t need to do anything extra to have this working in production. GitHub pages compiles Jekyll using the _config.yml file by default and ignores all other config files, but if your deployment is slightly different all you’d need to do is exclude the _config_dev.yml from the jekyll build command when doing your Jekyll build, and you should be good to go!