Jekyll: Development vs Production Settings
When I work on this site I generally run through a quick check to see if the content looks like I want it too. The downside to using Google Analytics, AdSense, and Disqus is that it really slows down the total load time of a page. While it’s not a huge problem when the site is just loading once it’s a little annoying when I’m loading it 10+ times in a row and making small changes.
In order to get around this I can add the following around any code block I only want on my live server (production):
{% if jekyll.environment == 'production' %}
Production only code
{% endif %}
The bonus to this is that if you use Github Pages to generate the pages for you it automatically uses the production environment.
If you’re self hosting like me you’ll need to specify the environment when you build the page:
JEKYLL_ENV=production jekyll build
I added this to my deploy script and it’s working well.
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows