Friday, May 9, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

Eleventy Starter Project Updates

February 11, 2024
in Front-Tech
Reading Time: 4 mins read
0 0
A A
0
Share on FacebookShare on Twitter


\"Eleventy

This blog uses static site generator Eleventy (or 11ty. I have no idea which one is the “official” spelling, and the docs appear to delight in switching gratuitously between the two! Let’s go with “Eleventy” for now.) under the hood. I like Eleventy because it allows me to write blog posts in markdown and use Nunjucks for templates, which get built into HTML file on deployment and served as static files, so it’s nice and lightweight on the client side. I also have an Eleventy starter project that’s been long-overdue for some maintenance. I recently made a few updates, so I thought I’d note them down here.

Out of the box, Eleventy doesn’t apply any kind of bundling or optimisation to your CSS and JS files — it’s up to you, the developer to bundle those if you wish. Now, perhaps you don’t need any kind of bundling of those files. It’s perfectly fine to serve up raw CSS and JS for a small project, and the Eleventy docs explain how to do that. To be honest, we could probably get away with that for this blog: even in their unoptimised form, the CSS and JS files would likely be smaller that those of most websites. But I wanted my starter project to be scaleable. I’ve been using Parcel to bundle CSS and JS files, but I knew I could make some improvements to streamline the build process.

What’s changed?

Sass variables to CSS

CSS custom properties are more versatile than Sass variables, as they can be changed in different contexts. Where possible, I prefer to use vanilla CSS features (when they’re well-supported). Eventually I’d like to remove reliance on Sass entirely, and this is the first step towards that.

Fluid type and spacing with Utopia

I’ve added custom properties for fluid typography and spacing using Utopia, one of my favourite tools that I find indispensable for working with modern CSS. These variables can be configured at the beginning of a project, and allow you to use values for padding, margins and typography that scale with the viewport — or even the container.

SVG sprite

Icons reference an SVG sprite as a separate file, rather than the sprite being inserted into the HTML of the page.

Simplified build process

I’ve upgraded to the latest Eleventy version, and instead of spinning up Browsersync I’m using the Eleventy dev server to watch template files and reload. As Stephanie notes:

…the default server is much faster and lighter and doesn’t require loading any JS during watch and serve local dev.

Because I’m using Parcel to bundle CSS and JS files, I just needed to add the source files as watch targets for Eleventy (in .eleventy.js), so that any changes to those will trigger a reload too.

module.exports = function (eleventyConfig) {
eleventyConfig.addWatchTarget(\’./src/css/\’)
eleventyConfig.addWatchTarget(\’./src/js/\’)
}

I’ve also simplified things by taking advantage of Eleventy’s addPassthroughCopy, which copies files or directories over to the deploy folder, instead of using Node to do this (as was the case in the previous version).

Blocking bots with robots.txt

I’ve added a robots.txt file that’s copied over to the output directory at build time. It has a few rules for blocking some known AI user agents so (theoretically) the site can’t be used to train AI large language and diffusion models.

What’s stayed the same?

Sass

The project still uses Sass, and Parcel makes it really easy to transform Sass to CSS with its transformer plugin. The main reason I’m still using Sass is for breakpoint variables (which aren’t possible with CSS) and nesting, which only became universally supported in vanilla CSS very recently. In a future iteration I’ll probably convert the whole project to vanilla CSS and do away with Sass entirely.

If you wanted to use the starter project with just vanilla CSS, you could swap out the Sass file for a CSS file (making sure to update the file path in layout.njk, and the source file in package.json).

Cache-busting

CSS and JS filenames are hashed on build using a Node script. Someone has made an Eleventy plugin for this which I guess I could implement instead, but my own code seems to work just fine, and it’s nice not to worry about an extra dependency.

Issues

You now need to run two commands to run the project locally, in order to run the Eleventy dev server and have Parcel watch CSS and JS files. I changed this because I was having a repeated issue where Eleventy would not respond the CTRL + C in the terminal and would continue to run. I assumed it was something to do with running Parcel at the same time, but in fact it still happens when I run Eleventy about 50% of the time. No idea why, I suspect it might be something to do with my Node environment.

Anyway, that’s my only gripe. I’m pretty happy with my setup!



Source link

Tags: cssEleventyfront endProjectstarterUpdatesweb designweb development
Previous Post

Jeff Bezos sells roughly $2 billion of Amazon shares By Reuters

Next Post

Taiwan reports more Chinese balloons over Taiwan Strait

Related Posts

The essential principles of a good homepage
Front-Tech

The essential principles of a good homepage

June 7, 2024
How to measure and improve user retention
Front-Tech

How to measure and improve user retention

June 6, 2024
Push Animation on Grid Items
Front-Tech

Push Animation on Grid Items

June 5, 2024
How to build a Rails API with rate limiting
Front-Tech

How to build a Rails API with rate limiting

June 4, 2024
Introduction to the B.I.A.S. framework
Front-Tech

Introduction to the B.I.A.S. framework

June 3, 2024
Blue Ridge Ruby is exactly what we need
Front-Tech

Blue Ridge Ruby is exactly what we need

June 3, 2024
Next Post
Taiwan reports more Chinese balloons over Taiwan Strait

Taiwan reports more Chinese balloons over Taiwan Strait

Top Data Science Specializations for 2024

Top Data Science Specializations for 2024

Sriracha shortage: Meet Craig Underwood, the chili pepper farming millionaire

Sriracha shortage: Meet Craig Underwood, the chili pepper farming millionaire

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
Porfo: Revolutionizing the Crypto Wallet Landscape

Porfo: Revolutionizing the Crypto Wallet Landscape

October 9, 2023
A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

May 19, 2024
A faster, better way to prevent an AI chatbot from giving toxic responses | MIT News

A faster, better way to prevent an AI chatbot from giving toxic responses | MIT News

April 10, 2024
Part 1: ABAP RESTful Application Programming Model (RAP) – Introduction

Part 1: ABAP RESTful Application Programming Model (RAP) – Introduction

November 20, 2023
Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

December 6, 2023
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In