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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
S
SegmentFault 最新的问题
Project Zero
Project Zero
D
DataBreaches.Net
I
InfoQ
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
The Register - Security
The Register - Security
Recorded Future
Recorded Future
Vercel News
Vercel News
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
I
Intezer
The Hacker News
The Hacker News
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Scott Helme
Scott Helme
T
Threatpost
爱范儿
爱范儿
N
Netflix TechBlog - Medium
D
Docker
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
K
Kaspersky official blog
H
Help Net Security
S
Secure Thoughts
T
Threat Research - Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
G
Google Developers Blog
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
B
Blog
Google DeepMind News
Google DeepMind News
Recent Announcements
Recent Announcements
Simon Willison's Weblog
Simon Willison's Weblog
S
Securelist
P
Privacy International News Feed
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog

CloudCannon Blog

Building with AI: Git-based vs headless vs traditional CMS CloudCannon + Astro: performance meets powerful content management Introducing the Astro Component Starter Introducing Jetstream — built on the Astro Component Starter Why we switched to the system font stack Redesigning CloudCannon’s docs with Diátaxis, Lume, and Pagefind Make content editing more visual: upgraded Editable Regions How Configuration Mode makes building editing interfaces easy Your hosting just got an upgrade (and a price cut) Custom testing domains for professional branding Keep your content consistent with input validation Managing multilingual content in CloudCannon Simplify team publishing with conflict resolution and domain tools Open Beta: Publishing Conflict Resolution Getting started with CloudCannon and Astro: Bookshop, components, and live editing Welcome to the CloudCannon Community! Omnichannel delivery is just marketing spin from API-based CMS companies Getting started with CloudCannon and Astro: Snippets and Collections Managing digital assets in CloudCannon: a guide to smart asset storage Understanding CloudCannon's branching workflows and Projects: a complete guide What is a static website? CloudCannon’s 2024 wrapped Getting started with CloudCannon and Astro: WYSIWYG blogging Jamstack vs. WordPress: reasons to make the change The top five static site generators for 2025 (and when to use them!) Free Jekyll themes for 2025: ten great community options Eleventy (11ty) vs. Hugo How to set up WYSIWYG editing with MkDocs Material The rise of static-first websites: why major brands are making the switch Watching your Core Web Vitals on Jamstack Understanding the difference between static, dynamic, and hybrid websites Looking for an alternative to Netlify CMS or Decap CMS? Designing components for your website editors: a CloudCannon case study Does my website look big in this? Six tips to lower your page weight Content is sacred — so own your revision history The eternal balancing act: load time vs. delay time Streamlined Headless Mode, Unified Configuration, and live data editing What is a headless CMS? Looking for a TinaCMS or Tina Cloud alternative? The ultimate guide to Hugo Sections Coming soon: Live config editing and data reloading Faster publishing workflows out now! Why information architecture matters for your website Website UX vs SEO: picking your battles Easily manage your multilingual Astro site in CloudCannon How you can optimize publishing workflows for your content team How you can optimize your CMS for SEO success How you can optimize your Content Editor for long-form articles How you can optimize your Visual Editor for page building Secure, swift, and stable: static sites for the financial sector Enhanced flexibility for teams with Custom Permissions Building static sites that scale The Inaugural 11ty International Symposium on Making Web Sites Real Good How to manage hundreds of connected websites with a Git-based headless CMS How we’re building CloudCannon for accessibility CloudCannon’s new editing improvements are here! Open Beta | New ways to collaborate on editing your websites Top 11 free Eleventy themes for 2024 Top 10 free Astro themes to use in 2024 Why choose a Git-based headless CMS over a monolithic DXP in 2024? Learning web development: a self-guided roadmap Partner Site of the Month: Blüthner Piano Centre, by Winteractive CloudCannon’s 2023 wrapup Let’s create a microblog with visual editing using Bookshop and Eleventy Update and visualize your branches with CloudCannon Projects What is a Git-based CMS and why you should use one CloudCannon secures SOC 2 certification The complete guide to growing your web development agency Automatically optimize your images with Eleventy Image and CloudCannon Share components and syndicate content with Site Mounting Partner Site of the Month: Cru Uncorked, by Ed Meehan New web component for responsive HTML tables Wrapping up HugoConf 2023 Partner Site of the Month: Van Dillen Antieke Bouwmaterialen, by Fulldev How to become a freelance web developer: a comprehensive guide Q3 2023: CloudCannon features and improvements 22 ways to deliver more value to your web development clients Partner Site of the Month: DC Gay Flag Football League, by Ed Cupaioli A new way to configure your CloudCannon sites CloudCannon — the official CMS partner of Eleventy Full CloudCannon support for Nuxt static sites Partner Site of the Month: Stadium Bike, by Insight Creative, Inc. HugoConf 2023, brought to you by CloudCannon DAM Support for Cloudflare R2 and DigitalOcean Spaces Eleventy (11ty) vs. Gatsby in 2023 – which SSG is best for you? How CloudCannon’s live editing works with Astro and Bookshop Partner Site of the Month: Fiducian, by Croissant & Baguette Eleventy (11ty) vs. Astro How to customize CloudCannon’s Client Sharing interface Let anyone, anywhere, edit your CloudCannon sites Top 23 free Astro themes for building out-of-this-world static sites in 2023 How Jampack optimizes our Eleventy website and improves performance Astro vs. Next.js CloudCannon.com is now built with Eleventy! Out-of-this-world support for all Astro users Introducing the CloudCannon Partner Program Full CloudCannon support for Gatsby Top 10 Free SvelteKit Themes for Building Lighting-Fast Static Sites in 2023 Enhanced CloudCannon support for Next.js users Upcoming CloudCannon Interface improvements (Open Beta)
Speed up your Jekyll builds
2017-12-08 · via CloudCannon Blog

Having a short Jekyll build time helps you iterate faster while developing and goes a long way to improving the experience for editors on CloudCannon. In this post, we're going over how to identify bottlenecks in your Jekyll build and tips on how to address them.

Jekyll version Direct link to this section

Let's start with the easiest way to improve build performance, update your Jekyll version! In the last year, Jekyll has made great strides in decreasing build time. Keeping an eye on the Jekyll news page and making sure you're using the latest version will go a long way to keeping your build time down.

Exclude folders Direct link to this section

Developers often use tools like Bower and npm to manage JavaScript and CSS libraries. These tools are great but they often produce files which aren't required when building your site. You can add these files to the exclude: key in your _config.yml. This prevents Jekyll having to copy them around every build.

Environment Direct link to this section

Your production site might need to be translated into multiple languages and have everything optimised to ensure fast load times but you can avoid these while developing. Turning these off for development along with limiting the number of posts output with --limit_posts and not switching on --lsi will have a massive impact on build performance.

Liquid Direct link to this section

Liquid is often the a culprit in slow build times. The first port of call for optimising Liquid is using the Liquid profiler:

bundle exec jekyll build --profile

This prints out a report of where Jekyll is spending its time rendering Liquid:

Filename                         | Count |    Bytes |  Time
---------------------------------+-------+----------+------
_layouts/default.html            |   222 | 3849.23K | 2.766
_layouts/post.html               |    52 | 1191.25K | 0.896
_includes/footer.html            |   222 |  536.36K | 0.596
_includes/navigation.html        |   222 |   87.61K | 0.345
_includes/listings.html          |    65 |  516.76K | 0.274
cheat-sheet.html                 |     1 |  146.32K | 0.224
_includes/social-icon.html       |   275 |  524.88K | 0.213
_includes/render_cheat.html      |     1 |  136.16K | 0.193
_includes/relative-src.html      |   222 |   36.21K | 0.173
_includes/right-navigation.html  |   222 |  119.24K | 0.124
sitemap.xml                      |     1 |    9.11K | 0.078
_includes/document-icon.html     |   295 |  186.81K | 0.078
_layouts/archive.html            |    12 |   54.95K | 0.077
_includes/search.html            |   222 |  129.86K | 0.076
_includes/share-section.html     |    52 |   48.80K | 0.063
feed.xml                         |     1 |   81.00K | 0.053
_includes/featured-icon.html     |    21 |  219.76K | 0.053
index.html                       |     1 |   36.62K | 0.047

The profiler gives us a baseline we can use to optimise individual files. Let's take _includes/footer.html from the example above. It's an include that iterates over a data file array:

<footer>
<ul class="footer-links">
{% for footer_item in site.data.footer %}
<li>
<a href="{{ footer_item.link }}">{{ footer_item.name }} </a>
</li>
{% endfor %}
</ul>
</footer>

This Liquid for loop looks innocent enough but it's included on every page on the site. If there are 1000 pages Jekyll has to execute this for loop 1000 times. The easiest way to optimise this is to output static HTML and avoid using Liquid:

<footer>
<ul class="footer-links">
<li>
<a href="https://facebook.com/CloudCannon">
Facebook
</a>
</li>
<li>
<a href="https://twitter.com/CloudCannon">
Twitter
</a>
</li>
<li>
<a href="https://www.youtube.com/channel/UC8CXR0-3I70i1tfPg1PAE1g">
YouTube
</a>
</li>
<li>
<a href="/feed.xml">
RSS
</a>
</li>
</ul>
</footer>

This is much faster but makes the site harder to maintain. We need the best of both worlds, the speed of static while having the flexibility of Liquid. We can achieve this with a Jekyll plugin. The plugin will generate the footer the first time it's run then cache the result for subsequent requests.

Ben Balter has solved this for us with his jekyll-include-cache plugin. To install add jekyll-include-cache to your Gemfile then run bundle install. Instead of calling {% include footer.html %} we call {% include_cached footer.html %}. This took the execution time of this file from 0.596 to 0.001.

The footer is easy to cache as is exactly the same on every page. Let's look at something that isn't the same on every page, the main navigation. _includes/navigation.html iterates over a data file, outputs a link and name then adds an active class if the link is the current page:

<nav>
{% for nav_item in site.data.navigation %}
<a href="{{ nav_item.link }}" {% if nav_item.link == page.url %}class="active"{% endif %}>
{{ nav_item.name }}
</a>
{% endfor %}
</nav>

If we included this using include_cached the active class will be on the same link on every page as it will execute it once then use that version for subsequent includes. We need to move the active page logic outside the include so we can cache it properly:

<nav>
{% for nav_item in site.data.navigation %}
<a href="{{ nav_item.link }}">{{ nav_item.name }}</a>
{% endfor %}
</nav>

From here we could rely on JavaScript/JQuery to add the active class:

$(function() {
$('nav a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
});

Or we could add a class to identify each nav item and a class to body in _layouts/default.html to identify the current page. The HTML output of the about page would look something like this:

...
<body class="about">
<nav>
<a href="/home/" class="home">
Home
</a>
<a href="/about/" class="about">
About
</a>
<a href="/contact/" class="contact">
Contact
</a>
</nav>
...

We can use those classes to highlight the current page:

.home .home, .about .about, .contact .contact { // Styles for active link
color: red;
text-decoration: underline;
}

If you're hosting on CloudCannon, a class of cc-active is automatically added to any links which point to the current page. This allows you to simply add a style for .cc-active in your CSS for active link highlighting.

Gems Direct link to this section

While it can be tempting to add every Jekyll plugin under the sun to your site, they can have a big impact on your build performance. The best way to understand the impact is to profile before and after adding a plugin. If you identify a slow plugin there are a few workarounds to consider:

Do you actually need the plugin? Direct link to this section

When I started using Jekyll I thought pagination was essential for any blog, however, our analytics told a different story. I realised that very few people click through the pagination pages, they're simply a way for search engines to find content. Instead of using pagination now we have a blog page which has our ten most recent posts and an archived page which has the rest. No plugins necessary.

Can you do this in frontend instead? Direct link to this section

One of the great things about Jekyll is you can have a piece of content which is used in different forms around your site. With a plugin like jekyll-picture-tag you can also apply this logic to images. For example, you might want to generate thumbnails on the fly for a series of photo gallery images. Instead of doing this in Jekyll using a plugin you can use a 3rd party so it doesn't slow down your build. Imgix, Cloudinary and weserv are all great candidates for doing this. You just need to tweak your image source so it's loaded from one of these services:

<img src="//images.weserv.nl/?url=mywebsite.com/cloud.jpg&w=300">

Can you do this with a post-processing tool? Direct link to this section

People have come up with ways to minify HTML using a layout, have a full asset pipeline inside Jekyll and perform other post-processing tasks. I would argue that while it's nice to have one tool do everything, they sit outside the scope of what Jekyll should be trying to do. Grunt and Gulp will perform much faster for these tasks and already have a huge library of scripts you can use.

Conclusion Direct link to this section

Jekyll has come a long way in decreasing building time. Knowing some of the constraints and working around them should give you speedy build times. If you have any other build performance tips and tricks leave them in the comments below!