Easily build accessible websites with 11ty, TailwindCSS and AlpineJS
14 |Ta11y is a simple 11ty template prepared to easily setup your next project with 11ty, TailwindCSS and AlpineJS.
17 | 18 |├── .gitattributes ├── src ├── views │ ├── robots.txt │ ├── img │ │ └── svg │ │ │ ├── mstile-70x70.png │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── favicon-96x96.png │ │ │ ├── mstile-144x144.png │ │ │ ├── mstile-150x150.png │ │ │ ├── mstile-310x150.png │ │ │ ├── mstile-310x310.png │ │ │ ├── Android Devices.png │ │ │ ├── Windows Devices.png │ │ │ ├── favicon-128x128.png │ │ │ ├── favicon-196x196.png │ │ │ ├── android-chrome-192x192.png │ │ │ ├── android-chrome-512x512.png │ │ │ ├── apple-touch-icon-76x76.png │ │ │ ├── apple-touch-icon-114x114.png │ │ │ ├── apple-touch-icon-120x120.png │ │ │ ├── apple-touch-icon-144x144.png │ │ │ ├── apple-touch-icon-152x152.png │ │ │ ├── apple-touch-icon-167x167.png │ │ │ ├── apple-touch-icon-180x180.png │ │ │ └── Apple Devices (iOS, iPadOS).png │ ├── pages │ │ ├── components.md │ │ ├── pages.11tydata.js │ │ └── features.md │ ├── _data │ │ └── site.js │ ├── category.njk │ ├── _includes │ │ ├── components │ │ │ ├── footer.njk │ │ │ ├── head.njk │ │ │ └── header.njk │ │ └── layouts │ │ │ ├── page.njk │ │ │ ├── base.njk │ │ │ └── single-post.njk │ ├── posts │ │ ├── what-is-accessibility.njk │ │ ├── what-do-you-want.njk │ │ ├── this-is-published-later.njk │ │ ├── posts.11tydata.js │ │ ├── auto-tag-archives.njk │ │ ├── index.njk │ │ └── handle-dates.njk │ ├── category-archive.njk │ ├── sitemap.njk │ ├── index.njk │ ├── manifest.json │ └── svg-previews.njk ├── main.js └── style.css ├── tailwind.config.js ├── package.json ├── .gitignore ├── README.md └── .eleventy.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /src/views/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | 3 | 4 | Sitemap: https://ta11y.app/sitemap.xml -------------------------------------------------------------------------------- /src/views/img/svg/mstile-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/mstile-70x70.png -------------------------------------------------------------------------------- /src/views/img/svg/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/favicon-16x16.png -------------------------------------------------------------------------------- /src/views/img/svg/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/favicon-32x32.png -------------------------------------------------------------------------------- /src/views/img/svg/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/favicon-96x96.png -------------------------------------------------------------------------------- /src/views/img/svg/mstile-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/mstile-144x144.png -------------------------------------------------------------------------------- /src/views/img/svg/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/mstile-150x150.png -------------------------------------------------------------------------------- /src/views/img/svg/mstile-310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/mstile-310x150.png -------------------------------------------------------------------------------- /src/views/img/svg/mstile-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/mstile-310x310.png -------------------------------------------------------------------------------- /src/views/img/svg/Android Devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/Android Devices.png -------------------------------------------------------------------------------- /src/views/img/svg/Windows Devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/Windows Devices.png -------------------------------------------------------------------------------- /src/views/img/svg/favicon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/favicon-128x128.png -------------------------------------------------------------------------------- /src/views/img/svg/favicon-196x196.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/favicon-196x196.png -------------------------------------------------------------------------------- /src/views/img/svg/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/android-chrome-192x192.png -------------------------------------------------------------------------------- /src/views/img/svg/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/android-chrome-512x512.png -------------------------------------------------------------------------------- /src/views/img/svg/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /src/views/img/svg/apple-touch-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/apple-touch-icon-114x114.png -------------------------------------------------------------------------------- /src/views/img/svg/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /src/views/img/svg/apple-touch-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/apple-touch-icon-144x144.png -------------------------------------------------------------------------------- /src/views/img/svg/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /src/views/img/svg/apple-touch-icon-167x167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/apple-touch-icon-167x167.png -------------------------------------------------------------------------------- /src/views/img/svg/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /src/views/img/svg/Apple Devices (iOS, iPadOS).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkBuskbjerg/ta11y/HEAD/src/views/img/svg/Apple Devices (iOS, iPadOS).png -------------------------------------------------------------------------------- /src/views/pages/components.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "A dream comin' true" 3 | --- 4 | 5 | I just dream of building out some really simple starter stuff, that I always use on my projects. 6 | -------------------------------------------------------------------------------- /src/views/_data/site.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | title: "Ta11y.app – 11ty starter project", 3 | url: "https://ta11y.app", 4 | language: "en", 5 | description: "I am writing about my experiences as a naval navel-gazer.", 6 | author: { 7 | name: "Your Name Here", 8 | email: "youremailaddress@example.com", 9 | url: "https://example.com/about-me/", 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /src/views/category.njk: -------------------------------------------------------------------------------- 1 | --- 2 | title: Alle kategorier 3 | layout: single-post 4 | seo: 5 | robots: noindex 6 | --- 7 | 8 |
Here comes an explanation of the setup. And how to use it.
11 | 12 |Probably also gonna make some text about how to copy it into your own setup.
-------------------------------------------------------------------------------- /src/views/category-archive.njk: -------------------------------------------------------------------------------- 1 | --- 2 | pagination: 3 | data: collections 4 | size: 1 5 | alias: tag 6 | eleventyComputed: 7 | title: 'Articles in category: "{{ tag }}"' 8 | permalink: /category/{{ tag | slugify }}/ 9 | layout: page 10 | seo: 11 | robots: noindex 12 | --- 13 | 14 |See all categories.
-------------------------------------------------------------------------------- /src/views/posts/this-is-published-later.njk: -------------------------------------------------------------------------------- 1 | --- 2 | title: Scheduled posts will be published later 3 | date: 2099-12-12 4 | tags: ['Example', 'Dates', 'Two words'] 5 | seo: 6 | title: "How to handle scheduled posts in 11ty (eleventy)" 7 | description: "With the right setup you can easily handle scheduled posts in your 11ty-setup. Read along here." 8 | --- 9 | 10 |If the date of the post is later than the current date for the build the value of draft will automatically be set to `true`.
11 | 12 |A downside to this approach is, that content is only handled on build. So if you only trigger your build manually scheduled posts won't be published.
-------------------------------------------------------------------------------- /src/views/_includes/layouts/base.njk: -------------------------------------------------------------------------------- 1 | 2 | 3 | {%- include 'components/head.njk' -%} 4 | 5 | Skip to main content 6 | {%- include 'components/header.njk' -%} 7 |Ta11y is a simple 11ty template prepared to easily setup your next project with 11ty, TailwindCSS and AlpineJS.
17 | 18 |Ta11y uses tags to sort all content in posts and automatically generate tag-archives with eleventy pagination.
10 | 11 | {%- highlight "html" -%} 12 | // Sample YAML header from post 13 | --- 14 | title: "This is the first post" 15 | tags: ['JavaScript', 'Tutorial'] 16 | --- 17 | {%- endhighlight -%} 18 | 19 | {%- highlight "html" -%} 20 | // Sample YAML header from post 21 | --- 22 | title: "This is the second post" 23 | tags: ['UX Design', 'Tutorial'] 24 | --- 25 | {%- endhighlight -%} 26 | 27 |This will generate three tag-archive pages:
28 | 29 |/category/javascript/ 👉 including the first post
30 |/category/ux-design/ 👉 including the second post
31 |/category/tutorial/ 👉 including both posts
-------------------------------------------------------------------------------- /src/views/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ta11y", 3 | "short_name": "ta11y", 4 | "description": "This is the ta11y 11ty starter project", 5 | "start_url": "/", 6 | "display": "standalone", 7 | "display_override": ["window-control-overlay", "standalone", "browser"], 8 | "lang": "en", 9 | "background_color": "#ffffff", 10 | "theme_color": "#000000", 11 | "orientation": "portrait-primary", 12 | "categories": ["education", "accessibility"], 13 | "dir": "ltr", 14 | "shortcuts": [ 15 | { 16 | "name": "All articles", 17 | "url": "/posts/", 18 | "description": "Read the latest articles" 19 | }, 20 | { 21 | "name": "Features", 22 | "url": "/features/", 23 | "description": "See a list of all avaiable features" 24 | } 25 | ], 26 | "icons": [ 27 | { 28 | "src": "/img/svg/android-chrome-192x192.png", 29 | "sizes": "192x192", 30 | "type": "image/png" 31 | }, 32 | { 33 | "src": "/img/svg/android-chrome-512x512.png", 34 | "sizes": "512x512", 35 | "type": "image/png", 36 | "purpose": "maskable any" 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /src/views/pages/features.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Features in ta11y" 3 | --- 4 | 5 | ## AlpineJS 6 | 7 | All interactive elements are handled with AlpineJS. AlpineJS is a lightweight alternative to VueJS. 8 | 9 | This gives you a double-whammy advantage. First of all you get to enjoy the speed of building your page with a lightweight framework such as Alpine.js. But it also means that you will easily be able to rewrite and replace AlpineJS with 10 | VueJS if you need to later on in your project. 11 | 12 | [Visit the docs for AlpineJS](https://alpinejs.dev/) 13 | 14 | ## TailwindCSS 3.3.2 15 | 16 | Ta11y is setup to use TailwindCSS 3.x.x and ready with Typography and Forms plugin out of the box. This means you get to use TailwindCSS for styling your website with everything handled, purged and optimized for a fast user experience. 17 | 18 | [Visit the docs for TailwindCSS](https://tailwindcss.com/) 19 | 20 | ## 11ty 2.0.1 21 | 22 | This project runs wild on 11ty 2.0. Enjoy. 23 | 24 | [Visit the docs for 11ty](https://www.11ty.dev/) 25 | 26 | ## Versatile templating options 27 | 28 | Use Nunjucks or Markdown interchangeably. 29 | 30 | ## Ready to boost your visibility in search engines (SEO) 31 | 32 | - YAML-structure to boost metadata is enabled 33 | - Preconfigured robots.txt 34 | - Preconfigured sitemap.xml 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ta11y", 3 | "version": "0.1.0", 4 | "description": "A simple 11ty starter project with complete TailwindCSS integration", 5 | "main": "index.js", 6 | "scripts": { 7 | "prod": "cross-env NODE_ENV=production ELEVENTY_ENV=production npm-run-all clean -p prod:*", 8 | "prod:11ty": "eleventy --quiet", 9 | "prod:css": "npx tailwindcss -i src/style.css -o _site/style.min.css --minify", 10 | "clean": "rimraf _site", 11 | "dev": "cross-env NODE_ENV=development ELEVENTY_ENV=development npm-run-all clean -p dev:*", 12 | "dev:11ty": "eleventy --serve --quiet" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/MarkBuskbjerg/ta11y.git" 17 | }, 18 | "keywords": [ 19 | "11ty", 20 | "tailwindcss", 21 | "alpine", 22 | "nunjucks", 23 | "ssg", 24 | "jamstack" 25 | ], 26 | "author": "Mark Buskbjerg", 27 | "license": "ISC", 28 | "bugs": { 29 | "url": "https://github.com/MarkBuskbjerg/ta11y/issues" 30 | }, 31 | "homepage": "https://github.com/MarkBuskbjerg/ta11y#readme", 32 | "devDependencies": { 33 | "@11ty/eleventy": "^2.0.1", 34 | "@11ty/eleventy-img": "^3.1.1", 35 | "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0", 36 | "@tailwindcss/forms": "^0.5.3", 37 | "@tailwindcss/typography": "^0.5.9", 38 | "autoprefixer": "^9.7.6", 39 | "base-64": "^0.1.0", 40 | "cross-env": "^7.0.2", 41 | "date-fns": "^2.29.3", 42 | "eleventy-plugin-pwa-v2": "^1.0.0", 43 | "fs": "^0.0.1-security", 44 | "npm-run-all": "^4.1.5", 45 | "postcss": "^8.4.23", 46 | "request": "^2.88.2", 47 | "rimraf": "^3.0.2", 48 | "tailwindcss": "^3.3.2", 49 | "vite": "^4.2.2" 50 | }, 51 | "dependencies": { 52 | "alpinejs": "^3.12.0" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/views/svg-previews.njk: -------------------------------------------------------------------------------- 1 | --- 2 | pagination: 3 | data: collections.allPosts 4 | size: 1 5 | alias: preview 6 | permalink: "/img/social-preview-images/{{ preview.data.date | datefmt }}-{{ preview.data.title | slug }}-preview.svg" 7 | eleventyExcludeFromCollections: true 8 | --- 9 | 10 | -------------------------------------------------------------------------------- /src/views/_includes/components/head.njk: -------------------------------------------------------------------------------- 1 | 2 | 3 |Scheduled
21 | {%- endif -%} 22 | 23 | {%- if post.data.draft -%} 24 |Draft
25 | {%- endif -%} 26 | 27 | {%- for tag in post.data.tags -%} 28 | {{ tag }} 29 | {%- endfor -%} 30 |Illo sint voluptas. Error voluptates culpa eligendi. Hic vel totam vitae illo. Non aliquid explicabo necessitatibus unde. Sed exercitationem placeat consectetur nulla deserunt vel iusto corrupti dicta laboris incididunt.
37 |See all categories.
43 |Out of the box ta11y use date-fns filter to format dates across the template. In this article I'll dive into how you can change the format globally or introduce new unique format filters.
To learn more about formatting dates with date-fns visit the date-fns docs 14 |
15 | 16 |By default dates are formatted as December 12th - 2023.
First we need to Initialize the filter in our 11ty setup. This is done in the file .eleventy.js.
Now we can use this filter on all date values in our eleventy-install. Like in this snip of code from the collection of posts:
37 | 38 | {%- highlight "html" -%} 39 | {%- raw -%} 40 | {%- if post.data.date -%} 41 | <time> datetime="{{- post.data.date -}}">{{- post.data.date | datefmt -}}</time> 42 | {%- else -%} 43 | <time> datetime="{{ page.date }}">{{- page.date | datefmt -}}</time> 44 | {%- endif -%} 45 | {%- endraw -%} 46 | {%- endhighlight -%} 47 | 48 | {%- highlight "html" -%} 49 | {%- raw -%} 50 | {{- page.date | datefmt -}} 51 | {% endraw %} 52 | {%- endhighlight -%} 53 | 54 |So ... let's say you wanted to display the weekday in the formatted date?
56 |Easy enough:
57 | 58 |Just jump straight into .eleventy.js and alter this line:
That is all it takes
-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A simple 11ty startersite using Tailwind CSS and AlpineJS 2 | 3 | A simple boilerplate built with Eleventy and TailwindCSS. 4 | 5 | This is a personal project and I'm still developing and tailoring it to my exact needs. I use it as my personal boilerplate for new projects. Hopefully you'll find inspiration or a good use for it yourself. 6 | 7 | I found a lot of inspiration from other open starter packs on 11ty.dev. Special thanks to [Skeleventy](https://github.com/josephdyer/skeleventy) and [Ta11ls](https://github.com/danfascia/tai11s). A lot of my structure is inspired by those 8 | starters. 9 | 10 | I try have it setup with a nice and simple starter design. But my main focus is to implement more technical parts like easy draft, scheduled post and navigation functionality. 11 | 12 | ## Features 13 | 14 | - Get started with a simple build process. 15 | - Easily handle drafts and scheduled posts both in production and development mode. 16 | - Built with accessibility (A11Y) in mind - feel free to suggest optimizations. 17 | - Layouts are build with Search Engine Optimization (SEO) in mind. 18 | - Blog / article section (will be ready with categories). 19 | - Templated with Nunjucks (.njk). 20 | - Free to use Nunjucks (.njk), Markdown (.md) or Liquid (.liquid) for all 21 | - Handle dates easily (use date-fns filters) 22 | - Category structure based on tags 23 | - Syntax highlighting 24 | 25 | ## Installation 26 | 27 | Download to your preferred local folder and run `npm install` from your terminal. 28 | 29 | To **start developing** type: 30 | 31 | `npm run dev` 32 | 33 | Your new Ta11y site will build and run in your preferred browser. 34 | 35 | To **run in production** type: 36 | 37 | `npm run prod` 38 | 39 | This displays everything totally purged and without any drafts and scheduled posts visible. 40 | 41 | ## Folder structure 42 | 43 | Everything is contained inside the 'src' folder. Organized like this 44 | 45 | - views 46 | -- pages 47 | -- posts 48 | - \_includes 49 | 50 | ## Why did I build Ta11y? 51 | 52 | Well. I needed something specifically tailored for my own projects. I've open-sourced it for others to use for either their own projects or just as inspiration. 53 | 54 | If you find it helpful in any way => I'm happy. If you have questions => Don't be a stranger :) If you find a bug => Please open an issue. 55 | 56 | ## Customize quickly from site.js data-file 57 | 58 | ## Roadmap and ideas 59 | 60 | Well. Just stuff I'd love to discover and get a handle on with this starter project. 61 | 62 | - Handling image and SVG-optimization 63 | - Better template-data in the of the page. Right now it is lacking a lot. 64 | - Custom 404 (ready for Netlify). 65 | - Write about how the site is setup. 66 | - Add better webmanifest-data. 67 | -------------------------------------------------------------------------------- /src/views/_includes/components/header.njk: -------------------------------------------------------------------------------- 1 |