xmitter-11ty/README.md

125 lines
6.4 KiB
Markdown
Raw Normal View History

2023-01-23 15:55:19 -05:00
# eleventy-base-blog v8
2018-01-16 22:08:47 -05:00
2023-02-24 17:20:11 -05:00
A starter repository showing how to build a blog with the [Eleventy](https://www.11ty.dev/) site generator (using the [v2.0 release](https://www.11ty.dev/blog/eleventy-v2/)).
2018-01-16 22:21:05 -05:00
2023-01-24 12:19:09 -05:00
[![Netlify Status](https://api.netlify.com/api/v1/badges/802669dd-d5f8-4d49-963d-6d57b257c2a2/deploy-status)](https://app.netlify.com/sites/eleventy-base-blog/deploys)
2018-01-16 22:21:05 -05:00
## Getting Started
2023-04-12 17:48:14 -04:00
* [Want a more generic/detailed getting started guide?](https://www.11ty.dev/docs/getting-started/)
1. Make a directory and navigate to it:
2018-01-16 22:21:05 -05:00
```
2023-04-12 17:48:14 -04:00
mkdir my-blog-name
cd my-blog-name
2018-01-16 22:21:05 -05:00
```
2023-04-12 17:48:14 -04:00
2. Clone this Repository
2018-01-16 22:21:05 -05:00
```
2023-04-12 17:48:14 -04:00
git clone https://github.com/11ty/eleventy-base-blog.git .
2018-01-16 22:21:05 -05:00
```
2023-04-12 17:48:14 -04:00
_Optional:_ Review `eleventy.config.js` and `_data/metadata.js` to configure the sites options and data.
3. Install dependencies
2018-01-16 22:21:05 -05:00
```
npm install
```
2023-04-12 17:48:14 -04:00
4. Run Eleventy
2018-01-16 22:21:05 -05:00
2023-04-12 17:48:14 -04:00
Generate a production-ready build to the `_site` folder:
2023-01-23 15:39:49 -05:00
2018-01-16 22:21:05 -05:00
```
npx @11ty/eleventy
2018-01-16 22:21:05 -05:00
```
2023-04-12 17:48:14 -04:00
Or build and host on a local development server:
```
npx @11ty/eleventy --serve
```
2023-02-24 17:19:27 -05:00
Or you can run [debug mode](https://www.11ty.dev/docs/debugging/) to see all the internals.
2018-01-16 22:34:35 -05:00
2023-02-24 17:15:24 -05:00
## Features
2023-02-24 17:20:11 -05:00
- Using [Eleventy v2.0](https://www.11ty.dev/blog/eleventy-v2/) with zero-JavaScript output.
2023-02-24 17:15:24 -05:00
- Content is exclusively pre-rendered (this is a static site).
- Can easily [deploy to a subfolder without changing any content](https://www.11ty.dev/docs/plugins/html-base/)
- All URLs are decoupled from the contents location on the file system.
- Configure templates via the [Eleventy Data Cascade](https://www.11ty.dev/docs/data-cascade/)
- **Performance focused**: four-hundos Lighthouse score out of the box!
- [View the Lighthouse report for the latest build](https://eleventy-base-blog.netlify.app/reports/lighthouse/) courtesy of the [Netlify Lighthouse plugin](https://github.com/netlify/netlify-plugin-lighthouse).
- _0 Cumulative Layout Shift_
- _0ms Total Blocking Time_
- Local development live reload provided by [Eleventy Dev Server](https://www.11ty.dev/docs/dev-server/).
- Content-driven [navigation menu](https://www.11ty.dev/docs/plugins/navigation/)
- [Image optimization](https://www.11ty.dev/docs/plugins/image/) via the `{% image %}` shortcode.
- Zero-JavaScript output.
- Support for modern image formats automatically (e.g. AVIF and WebP)
- Prefers `<img>` markup if possible (single image format) but switches automatically to `<picture>` for multiple image formats.
- Automated `<picture>` syntax markup with `srcset` and optional `sizes`
- Includes `width`/`height` attributes to avoid [content layout shift](https://web.dev/cls/).
- Includes `loading="lazy"` for native lazy loading without JavaScript.
- Includes [`decoding="async"`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decoding)
- Images can be co-located with blog post files.
- View the [Image plugin source code](https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.images.js)
- Per page CSS bundles [via `eleventy-plugin-bundle`](https://github.com/11ty/eleventy-plugin-bundle).
- Built-in [syntax highlighter](https://www.11ty.dev/docs/plugins/syntaxhighlight/) (zero-JavaScript output).
- Blog Posts
- Draft posts: use `draft: true` to mark a blog post as a draft. Drafts are **only** included during `--serve`/`--watch` and are excluded from full builds. View the [Drafts plugin source code](https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.drafts.js).
- Automated next/previous links
- Accessible deep links to headings
- Generated Pages
- Home, Archive, and About pages.
- [Feeds for Atom and JSON](https://www.11ty.dev/docs/plugins/rss/)
- `sitemap.xml`
- Zero-maintenance tag pages ([View on the Demo](https://eleventy-base-blog.netlify.app/tags/))
- Content not found (404) page
## Demos
- [Netlify](https://eleventy-base-blog.netlify.com/)
- [GitHub Pages](https://11ty.github.io/eleventy-base-blog/)
- [Remix on Glitch](https://glitch.com/~11ty-eleventy-base-blog)
## Deploy this to your own site
Deploy this Eleventy site in just a few clicks on these services:
- [Get your own Eleventy web site on Netlify](https://app.netlify.com/start/deploy?repository=https://github.com/11ty/eleventy-base-blog)
- If you run Eleventy locally you can drag your `_site` folder to [`drop.netlify.com`](https://drop.netlify.com/) to upload it without using `git`.
- [Get your own Eleventy web site on Vercel](https://vercel.com/import/project?template=11ty%2Feleventy-base-blog)
- [Try it out on Stackblitz](https://stackblitz.com/github/11ty/eleventy-base-blog)
2023-02-24 17:15:24 -05:00
- Read more about [Deploying an Eleventy project](https://www.11ty.dev/docs/deployment/) to the web.
2018-01-16 22:34:35 -05:00
### Implementation Notes
- `content/about/index.md` is an example of a content page.
2023-03-23 06:47:12 -04:00
- `content/blog/` has the blog posts but really they can live in any directory. They need only the `posts` tag to be included in the blog posts [collection](https://www.11ty.dev/docs/collections/).
- Use the `eleventyNavigation` key (via the [Eleventy Navigation plugin](https://www.11ty.dev/docs/plugins/navigation/)) in your front matter to add a template to the top level site navigation. This is in use on `content/index.njk` and `content/about/index.md`.
2023-01-23 15:39:49 -05:00
- Content can be in _any template format_ (blog posts neednt exclusively be markdown, for example). Configure your projects supported templates in `eleventy.config.js` -> `templateFormats`.
2023-01-23 11:02:06 -05:00
- The `public` folder in your input directory will be copied to the output folder (via `addPassthroughCopy` in the `eleventy.config.js` file). This means `./public/css/*` will live at `./_site/css/*` after your build completes.
2023-01-24 12:31:42 -05:00
- Provides two content feeds:
- `content/feed/feed.njk`
- `content/feed/json.njk`
- This project uses three [Eleventy Layouts](https://www.11ty.dev/docs/layouts/):
- `_includes/layouts/base.njk`: the top level HTML structure
- `_includes/layouts/home.njk`: the home page template (wrapped into `base.njk`)
- `_includes/layouts/post.njk`: the blog post template (wrapped into `base.njk`)
- `_includes/postslist.njk` is a Nunjucks include and is a reusable component used to display a list of all the posts. `content/index.njk` has an example of how to use it.
If your site enforces a Content Security Policy (as public-facing sites should), either, in `base.njk`, disable
```html
<style>{% getBundle "css" %}</style>
```
and enable
```html
<link rel="stylesheet" href="{% getBundleFileUrl "css" %}">
```
or configure the server with the CSP directive `style-src: 'unsafe-inline'` (which is less secure).