├── .nvmrc ├── img └── .gitkeep ├── .eleventyignore ├── .gitignore ├── posts ├── posts.json ├── fourthpost.md ├── secondpost.md ├── firstpost.md └── thirdpost.md ├── netlify.toml ├── .github └── FUNDING.yml ├── _includes ├── layouts │ ├── home.njk │ ├── post.njk │ └── base.njk └── postslist.njk ├── .editorconfig ├── about └── index.md ├── archive.njk ├── feed ├── htaccess.njk ├── json.njk └── feed.njk ├── tags-list.njk ├── index.njk ├── .travis.yml ├── sitemap.xml.njk ├── 404.md ├── tags.njk ├── page-list.njk ├── _data └── metadata.json ├── LICENSE ├── package.json ├── css ├── prism-base16-monokai.dark.css └── index.css ├── README.md └── .eleventy.js /.nvmrc: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /img/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.eleventyignore: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _site/ 2 | node_modules/ 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /posts/posts.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": [ 3 | "posts" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "_site" 3 | command = "DEBUG=* eleventy" -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | open_collective: 11ty 3 | -------------------------------------------------------------------------------- /_includes/layouts/home.njk: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/base.njk 3 | templateClass: tmpl-home 4 | --- 5 | {{ content | safe }} 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | charset = utf-8 10 | -------------------------------------------------------------------------------- /about/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/post.njk 3 | title: About Me 4 | templateClass: tmpl-post 5 | eleventyNavigation: 6 | key: About Me 7 | order: 3 8 | --- 9 | 10 | I am a person that writes stuff. 11 | -------------------------------------------------------------------------------- /archive.njk: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/home.njk 3 | permalink: /posts/ 4 | eleventyNavigation: 5 | key: Archive 6 | order: 2 7 | --- 8 | 9 |

Archive

10 | 11 | {% set postslist = collections.posts %} 12 | {% include "postslist.njk" %} 13 | -------------------------------------------------------------------------------- /feed/htaccess.njk: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: feed/.htaccess 3 | eleventyExcludeFromCollections: true 4 | --- 5 | # For Apache, to show `{{ metadata.feed.filename }}` when browsing to directory /feed/ (hide the file!) 6 | DirectoryIndex {{ metadata.feed.filename }} 7 | -------------------------------------------------------------------------------- /tags-list.njk: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: /tags/ 3 | layout: layouts/home.njk 4 | --- 5 |

Tags

6 | 7 | {% for tag in collections.tagList %} 8 | {% set tagUrl %}/tags/{{ tag }}/{% endset %} 9 | {{ tag }} 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /index.njk: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/home.njk 3 | eleventyNavigation: 4 | key: Home 5 | order: 1 6 | --- 7 | 8 |

Latest 3 Posts

9 | 10 | {% set postslist = collections.posts | head(-3) %} 11 | {% set postslistCounter = collections.posts | length %} 12 | {% include "postslist.njk" %} 13 | 14 |

More posts can be found in the archive.

15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 8 4 | before_script: 5 | - npm install @11ty/eleventy -g 6 | script: eleventy --pathprefix="/eleventy-base-blog/" 7 | deploy: 8 | local-dir: _site 9 | provider: pages 10 | skip-cleanup: true 11 | github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure 12 | keep-history: true 13 | on: 14 | branch: master 15 | -------------------------------------------------------------------------------- /sitemap.xml.njk: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: /sitemap.xml 3 | eleventyExcludeFromCollections: true 4 | --- 5 | 6 | 7 | {%- for page in collections.all %} 8 | {% set absoluteUrl %}{{ page.url | url | absoluteUrl(metadata.url) }}{% endset %} 9 | 10 | {{ absoluteUrl }} 11 | {{ page.date | htmlDateString }} 12 | 13 | {%- endfor %} 14 | 15 | -------------------------------------------------------------------------------- /404.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/home.njk 3 | permalink: 404.html 4 | eleventyExcludeFromCollections: true 5 | --- 6 | # Content not found. 7 | 8 | Go home. 9 | 10 | {% comment %} 11 | Read more: https://www.11ty.dev/docs/quicktips/not-found/ 12 | 13 | This will work for both GitHub pages and Netlify: 14 | 15 | * https://help.github.com/articles/creating-a-custom-404-page-for-your-github-pages-site/ 16 | * https://www.netlify.com/docs/redirects/#custom-404 17 | {% endcomment %} 18 | -------------------------------------------------------------------------------- /tags.njk: -------------------------------------------------------------------------------- 1 | --- 2 | pagination: 3 | data: collections 4 | size: 1 5 | alias: tag 6 | filter: 7 | - all 8 | - nav 9 | - post 10 | - posts 11 | - tagList 12 | addAllPagesToCollections: true 13 | layout: layouts/home.njk 14 | eleventyComputed: 15 | title: Tagged “{{ tag }}” 16 | permalink: /tags/{{ tag }}/ 17 | --- 18 |

Tagged “{{ tag }}”

19 | 20 | {% set postslist = collections[ tag ] %} 21 | {% include "postslist.njk" %} 22 | 23 |

See all tags.

24 | -------------------------------------------------------------------------------- /page-list.njk: -------------------------------------------------------------------------------- 1 | --- 2 | pagination: 3 | data: collections.all 4 | size: 20 5 | alias: entries 6 | layout: layouts/home.njk 7 | permalink: /page-list/{% if pagination.pageNumber > 0 %}{{ pagination.pageNumber }}/{% endif %} 8 | --- 9 | 10 | 11 | 12 | 13 | 14 | 15 | {%- for entry in entries %} 16 | 17 | 18 | 19 | 20 | {%- endfor %} 21 | 22 |
URLPage Title
{{ entry.url }}{{ entry.data.title }}
23 | -------------------------------------------------------------------------------- /_includes/layouts/post.njk: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/base.njk 3 | templateClass: tmpl-post 4 | --- 5 |

{{ title }}

6 | 7 | {{ content | safe }} 8 | 9 |
10 | 16 | -------------------------------------------------------------------------------- /_data/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Your Blog Name", 3 | "url": "https://example.com/", 4 | "description": "I am writing about my experiences as a naval navel-gazer.", 5 | "feed": { 6 | "subtitle": "I am writing about my experiences as a naval navel-gazer.", 7 | "filename": "feed.xml", 8 | "path": "/feed/feed.xml", 9 | "id": "https://example.com/" 10 | }, 11 | "jsonfeed": { 12 | "path": "/feed/feed.json", 13 | "url": "https://example.com/feed/feed.json" 14 | }, 15 | "author": { 16 | "name": "Your Name Here", 17 | "email": "youremailaddress@example.com", 18 | "url": "https://example.com/about-me/" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /_includes/postslist.njk: -------------------------------------------------------------------------------- 1 |
    2 | {% for post in postslist | reverse %} 3 |
  1. 4 | {% if post.data.title %}{{ post.data.title }}{% else %}{{ post.url }}{% endif %} 5 | 6 | {% for tag in post.data.tags %} 7 | {%- if collections.tagList.indexOf(tag) != -1 -%} 8 | {% set tagUrl %}/tags/{{ tag }}/{% endset %} 9 | 10 | {%- endif -%} 11 | {% endfor %} 12 |
  2. 13 | {% endfor %} 14 |
15 | -------------------------------------------------------------------------------- /feed/json.njk: -------------------------------------------------------------------------------- 1 | --- 2 | # Metadata comes from _data/metadata.json 3 | permalink: "{{ metadata.jsonfeed.path | url }}" 4 | eleventyExcludeFromCollections: true 5 | --- 6 | { 7 | "version": "https://jsonfeed.org/version/1", 8 | "title": "{{ metadata.title }}", 9 | "home_page_url": "{{ metadata.url }}", 10 | "feed_url": "{{ metadata.jsonfeed.url }}", 11 | "description": "{{ metadata.description }}", 12 | "author": { 13 | "name": "{{ metadata.author.name }}", 14 | "url": "{{ metadata.author.url }}" 15 | }, 16 | "items": [ 17 | {%- for post in collections.posts | reverse %} 18 | {%- set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset -%} 19 | { 20 | "id": "{{ absolutePostUrl }}", 21 | "url": "{{ absolutePostUrl }}", 22 | "title": "{{ post.data.title }}", 23 | "content_html": {% if post.templateContent %}{{ post.templateContent | dump | safe }}{% else %}""{% endif %}, 24 | "date_published": "{{ post.date | rssDate }}" 25 | } 26 | {%- if not loop.last -%} 27 | , 28 | {%- endif -%} 29 | {%- endfor %} 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /posts/fourthpost.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: This is my fourth post. 3 | description: This is a post on My Blog about touchpoints and circling wagons. 4 | date: 2018-09-30 5 | tags: second-tag 6 | layout: layouts/post.njk 7 | --- 8 | Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. 9 | 10 | Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring. 11 | 12 | ## Section Header 13 | 14 | Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line. 15 | 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Zach Leatherman @zachleat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eleventy-base-blog", 3 | "version": "5.0.2", 4 | "description": "A starter repository for a blog web site using the Eleventy static site generator.", 5 | "scripts": { 6 | "build": "eleventy", 7 | "watch": "eleventy --watch", 8 | "serve": "eleventy --serve", 9 | "start": "eleventy --serve", 10 | "debug": "DEBUG=* eleventy" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git://github.com/11ty/eleventy-base-blog.git" 15 | }, 16 | "author": { 17 | "name": "Zach Leatherman", 18 | "email": "zachleatherman@gmail.com", 19 | "url": "https://zachleat.com/" 20 | }, 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/11ty/eleventy-base-blog/issues" 24 | }, 25 | "homepage": "https://github.com/11ty/eleventy-base-blog#readme", 26 | "devDependencies": { 27 | "@11ty/eleventy": "^0.11.0", 28 | "@11ty/eleventy-navigation": "^0.1.6", 29 | "@11ty/eleventy-plugin-rss": "^1.0.9", 30 | "@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1", 31 | "luxon": "^1.21.3", 32 | "markdown-it": "^8.4.2", 33 | "markdown-it-anchor": "^5.2.5" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /feed/feed.njk: -------------------------------------------------------------------------------- 1 | --- 2 | # Metadata comes from _data/metadata.json 3 | permalink: "{{ metadata.feed.path | url }}" 4 | eleventyExcludeFromCollections: true 5 | --- 6 | 7 | 8 | {{ metadata.title }} 9 | {{ metadata.feed.subtitle }} 10 | {% set absoluteUrl %}{{ metadata.feed.path | url | absoluteUrl(metadata.url) }}{% endset %} 11 | 12 | 13 | {{ collections.posts | rssLastUpdatedDate }} 14 | {{ metadata.feed.id }} 15 | 16 | {{ metadata.author.name }} 17 | {{ metadata.author.email }} 18 | 19 | {%- for post in collections.posts | reverse %} 20 | {% set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset %} 21 | 22 | {{ post.data.title }} 23 | 24 | {{ post.date | rssDate }} 25 | {{ absolutePostUrl }} 26 | {{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }} 27 | 28 | {%- endfor %} 29 | 30 | -------------------------------------------------------------------------------- /posts/secondpost.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: This is my second post. 3 | description: This is a post on My Blog about leveraging agile frameworks. 4 | date: 2018-07-04 5 | tags: 6 | - number-2 7 | layout: layouts/post.njk 8 | --- 9 | Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. 10 | 11 | ## Section Header 12 | 13 | First post 14 | Third post 15 | 16 | Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring. 17 | 18 | Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line. 19 | -------------------------------------------------------------------------------- /posts/firstpost.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: This is my first post. 3 | description: This is a post on My Blog about agile frameworks. 4 | date: 2018-05-01 5 | tags: 6 | - another-tag 7 | layout: layouts/post.njk 8 | --- 9 | Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. 10 | 11 | Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring. 12 | 13 | ## Section Header 14 | 15 | Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line. 16 | 17 | ``` text/2-3 18 | // this is a command 19 | function myCommand() { 20 | let counter = 0; 21 | counter++; 22 | } 23 | 24 | // Test with a line break above this line. 25 | console.log('Test'); 26 | ``` 27 | -------------------------------------------------------------------------------- /posts/thirdpost.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: This is my third post. 3 | description: This is a post on My Blog about win-win survival strategies. 4 | date: 2018-08-24 5 | tags: 6 | - second-tag 7 | layout: layouts/post.njk 8 | --- 9 | Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. 10 | 11 | ``` js/2/4 12 | // this is a command 13 | function myCommand() { 14 | let counter = 0; 15 | 16 | counter++; 17 | 18 | } 19 | 20 | // Test with a line break above this line. 21 | console.log('Test'); 22 | ``` 23 | 24 | Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring. 25 | 26 | ## Section Header 27 | 28 | Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line. 29 | -------------------------------------------------------------------------------- /css/prism-base16-monokai.dark.css: -------------------------------------------------------------------------------- 1 | code[class*="language-"], pre[class*="language-"] { 2 | font-size: 14px; 3 | line-height: 1.375; 4 | direction: ltr; 5 | text-align: left; 6 | white-space: pre; 7 | word-spacing: normal; 8 | word-break: normal; 9 | -moz-tab-size: 2; 10 | -o-tab-size: 2; 11 | tab-size: 2; 12 | -webkit-hyphens: none; 13 | -moz-hyphens: none; 14 | -ms-hyphens: none; 15 | hyphens: none; 16 | background: #272822; 17 | color: #f8f8f2; 18 | } 19 | pre[class*="language-"] { 20 | padding: 1.5em 0; 21 | margin: .5em 0; 22 | overflow: auto; 23 | } 24 | :not(pre) > code[class*="language-"] { 25 | padding: .1em; 26 | border-radius: .3em; 27 | } 28 | .token.comment, .token.prolog, .token.doctype, .token.cdata { 29 | color: #75715e; 30 | } 31 | .token.punctuation { 32 | color: #f8f8f2; 33 | } 34 | .token.namespace { 35 | opacity: .7; 36 | } 37 | .token.operator, .token.boolean, .token.number { 38 | color: #fd971f; 39 | } 40 | .token.property { 41 | color: #f4bf75; 42 | } 43 | .token.tag { 44 | color: #66d9ef; 45 | } 46 | .token.string { 47 | color: #a1efe4; 48 | } 49 | .token.selector { 50 | color: #ae81ff; 51 | } 52 | .token.attr-name { 53 | color: #fd971f; 54 | } 55 | .token.entity, .token.url, .language-css .token.string, .style .token.string { 56 | color: #a1efe4; 57 | } 58 | .token.attr-value, .token.keyword, .token.control, .token.directive, .token.unit { 59 | color: #a6e22e; 60 | } 61 | .token.statement, .token.regex, .token.atrule { 62 | color: #a1efe4; 63 | } 64 | .token.placeholder, .token.variable { 65 | color: #66d9ef; 66 | } 67 | .token.deleted { 68 | text-decoration: line-through; 69 | } 70 | .token.inserted { 71 | border-bottom: 1px dotted #f9f8f5; 72 | text-decoration: none; 73 | } 74 | .token.italic { 75 | font-style: italic; 76 | } 77 | .token.important, .token.bold { 78 | font-weight: bold; 79 | } 80 | .token.important { 81 | color: #f92672; 82 | } 83 | .token.entity { 84 | cursor: help; 85 | } 86 | pre > code.highlight { 87 | outline: 0.4em solid #f92672; 88 | outline-offset: .4em; 89 | } 90 | -------------------------------------------------------------------------------- /_includes/layouts/base.njk: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ title or metadata.title }} 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

{{ metadata.title }}

16 | 17 | {#- Read more about `eleventy-navigation` at https://www.11ty.dev/docs/plugins/navigation/ #} 18 | 23 |
24 | 25 | 26 | 27 | 28 |
29 |
    30 |
  1. Edit the _data/metadata.json with your blog’s information.
  2. 31 |
  3. (Optional) Edit .eleventy.js with your configuration preferences.
  4. 32 |
  5. Delete this message from _includes/layouts/base.njk.
  6. 33 |
34 |

This is an Eleventy project created from the eleventy-base-blog repo.

35 |
36 | 37 | 38 | {{ content | safe }} 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eleventy-base-blog 2 | 3 | A starter repository showing how to build a blog with the [Eleventy](https://github.com/11ty/eleventy) static site generator. 4 | 5 | [![Build Status](https://travis-ci.org/11ty/eleventy-base-blog.svg?branch=master)](https://travis-ci.org/11ty/eleventy-base-blog) 6 | 7 | ## Demos 8 | 9 | * [Netlify](https://eleventy-base-blog.netlify.com/) 10 | * [GitHub Pages](https://11ty.github.io/eleventy-base-blog/) 11 | * [Remix on Glitch](https://glitch.com/~11ty-eleventy-base-blog) 12 | 13 | ## Deploy this to your own site 14 | 15 | These builders are amazing—try them out to get your own Eleventy site in a few clicks! 16 | 17 | * [Get your own Eleventy web site on Netlify](https://app.netlify.com/start/deploy?repository=https://github.com/11ty/eleventy-base-blog) 18 | * [Get your own Eleventy web site on Vercel](https://vercel.com/import/project?template=11ty%2Feleventy-base-blog) 19 | 20 | ## Getting Started 21 | 22 | ### 1. Clone this Repository 23 | 24 | ``` 25 | git clone https://github.com/11ty/eleventy-base-blog.git my-blog-name 26 | ``` 27 | 28 | 29 | ### 2. Navigate to the directory 30 | 31 | ``` 32 | cd my-blog-name 33 | ``` 34 | 35 | Specifically have a look at `.eleventy.js` to see if you want to configure any Eleventy options differently. 36 | 37 | ### 3. Install dependencies 38 | 39 | ``` 40 | npm install 41 | ``` 42 | 43 | ### 4. Edit _data/metadata.json 44 | 45 | ### 5. Run Eleventy 46 | 47 | ``` 48 | npx eleventy 49 | ``` 50 | 51 | Or build and host locally for local development 52 | ``` 53 | npx eleventy --serve 54 | ``` 55 | 56 | Or build automatically when a template changes: 57 | ``` 58 | npx eleventy --watch 59 | ``` 60 | 61 | Or in debug mode: 62 | ``` 63 | DEBUG=* npx eleventy 64 | ``` 65 | 66 | ### Implementation Notes 67 | 68 | * `about/index.md` shows how to add a content page. 69 | * `posts/` has the blog posts but really they can live in any directory. They need only the `post` tag to be added to this collection. 70 | * Add the `nav` tag to add a template to the top level site navigation. For example, this is in use on `index.njk` and `about/index.md`. 71 | * Content can be any template format (blog posts needn’t be markdown, for example). Configure your supported templates in `.eleventy.js` -> `templateFormats`. 72 | * Because `css` and `png` are listed in `templateFormats` but are not supported template types, any files with these extensions will be copied without modification to the output (while keeping the same directory structure). 73 | * The blog post feed template is in `feed/feed.njk`. This is also a good example of using a global data files in that it uses `_data/metadata.json`. 74 | * This example uses three layouts: 75 | * `_includes/layouts/base.njk`: the top level HTML structure 76 | * `_includes/layouts/home.njk`: the home page template (wrapped into `base.njk`) 77 | * `_includes/layouts/post.njk`: the blog post template (wrapped into `base.njk`) 78 | * `_includes/postlist.njk` is a Nunjucks include and is a reusable component used to display a list of all the posts. `index.njk` has an example of how to use it. 79 | -------------------------------------------------------------------------------- /.eleventy.js: -------------------------------------------------------------------------------- 1 | const { DateTime } = require("luxon"); 2 | const fs = require("fs"); 3 | const pluginRss = require("@11ty/eleventy-plugin-rss"); 4 | const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); 5 | const pluginNavigation = require("@11ty/eleventy-navigation"); 6 | const markdownIt = require("markdown-it"); 7 | const markdownItAnchor = require("markdown-it-anchor"); 8 | 9 | module.exports = function(eleventyConfig) { 10 | eleventyConfig.addPlugin(pluginRss); 11 | eleventyConfig.addPlugin(pluginSyntaxHighlight); 12 | eleventyConfig.addPlugin(pluginNavigation); 13 | 14 | eleventyConfig.setDataDeepMerge(true); 15 | 16 | eleventyConfig.addLayoutAlias("post", "layouts/post.njk"); 17 | 18 | eleventyConfig.addFilter("readableDate", dateObj => { 19 | return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat("dd LLL yyyy"); 20 | }); 21 | 22 | // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string 23 | eleventyConfig.addFilter('htmlDateString', (dateObj) => { 24 | return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd'); 25 | }); 26 | 27 | // Get the first `n` elements of a collection. 28 | eleventyConfig.addFilter("head", (array, n) => { 29 | if( n < 0 ) { 30 | return array.slice(n); 31 | } 32 | 33 | return array.slice(0, n); 34 | }); 35 | 36 | eleventyConfig.addCollection("tagList", function(collection) { 37 | let tagSet = new Set(); 38 | collection.getAll().forEach(function(item) { 39 | if( "tags" in item.data ) { 40 | let tags = item.data.tags; 41 | 42 | tags = tags.filter(function(item) { 43 | switch(item) { 44 | // this list should match the `filter` list in tags.njk 45 | case "all": 46 | case "nav": 47 | case "post": 48 | case "posts": 49 | return false; 50 | } 51 | 52 | return true; 53 | }); 54 | 55 | for (const tag of tags) { 56 | tagSet.add(tag); 57 | } 58 | } 59 | }); 60 | 61 | // returning an array in addCollection works in Eleventy 0.5.3 62 | return [...tagSet]; 63 | }); 64 | 65 | eleventyConfig.addPassthroughCopy("img"); 66 | eleventyConfig.addPassthroughCopy("css"); 67 | 68 | /* Markdown Overrides */ 69 | let markdownLibrary = markdownIt({ 70 | html: true, 71 | breaks: true, 72 | linkify: true 73 | }).use(markdownItAnchor, { 74 | permalink: true, 75 | permalinkClass: "direct-link", 76 | permalinkSymbol: "#" 77 | }); 78 | eleventyConfig.setLibrary("md", markdownLibrary); 79 | 80 | // Browsersync Overrides 81 | eleventyConfig.setBrowserSyncConfig({ 82 | callbacks: { 83 | ready: function(err, browserSync) { 84 | const content_404 = fs.readFileSync('_site/404.html'); 85 | 86 | browserSync.addMiddleware("*", (req, res) => { 87 | // Provides the 404 content without redirect. 88 | res.write(content_404); 89 | res.end(); 90 | }); 91 | }, 92 | }, 93 | ui: false, 94 | ghostMode: false 95 | }); 96 | 97 | return { 98 | templateFormats: [ 99 | "md", 100 | "njk", 101 | "html", 102 | "liquid" 103 | ], 104 | 105 | // If your site lives in a different subdirectory, change this. 106 | // Leading or trailing slashes are all normalized away, so don’t worry about those. 107 | 108 | // If you don’t have a subdirectory, use "" or "/" (they do the same thing) 109 | // This is only used for link URLs (it does not affect your file structure) 110 | // Best paired with the `url` filter: https://www.11ty.dev/docs/filters/url/ 111 | 112 | // You can also pass this in on the command line using `--pathprefix` 113 | // pathPrefix: "/", 114 | 115 | markdownTemplateEngine: "liquid", 116 | htmlTemplateEngine: "njk", 117 | dataTemplateEngine: "njk", 118 | 119 | // These are all optional, defaults are shown: 120 | dir: { 121 | input: ".", 122 | includes: "_includes", 123 | data: "_data", 124 | output: "_site" 125 | } 126 | }; 127 | }; 128 | -------------------------------------------------------------------------------- /css/index.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --red: #C5004A; 3 | --darkred: #7F0036; 4 | --lightgray: #e0e0e0; 5 | --gray: #C0C0C0; 6 | --darkgray: #333; 7 | --navy: #17050F; 8 | --blue: #082840; 9 | --white: #fff; 10 | } 11 | * { 12 | box-sizing: border-box; 13 | } 14 | html, 15 | body { 16 | padding: 0; 17 | margin: 0; 18 | font-family: system-ui, sans-serif; 19 | color: var(--darkgray); 20 | background-color: var(--white); 21 | } 22 | p:last-child { 23 | margin-bottom: 0; 24 | } 25 | p, 26 | .tmpl-post li, 27 | img { 28 | max-width: 37.5em; /* 600px /16 */ 29 | } 30 | p, 31 | .tmpl-post li { 32 | line-height: 1.45; 33 | } 34 | a[href] { 35 | color: var(--blue); 36 | } 37 | a[href]:visited { 38 | color: var(--navy); 39 | } 40 | main { 41 | padding: 1rem; 42 | } 43 | main :first-child { 44 | margin-top: 0; 45 | } 46 | header { 47 | border-bottom: 1px dashed var(--lightgray); 48 | } 49 | header:after { 50 | content: ""; 51 | display: table; 52 | clear: both; 53 | } 54 | table { 55 | margin: 1em 0; 56 | } 57 | table td, 58 | table th { 59 | padding-right: 1em; 60 | } 61 | 62 | pre, 63 | code { 64 | font-family: Consolas, Menlo, Monaco, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", "Courier New", Courier, monospace; 65 | line-height: 1.5; 66 | } 67 | pre { 68 | font-size: 14px; 69 | line-height: 1.375; 70 | direction: ltr; 71 | text-align: left; 72 | white-space: pre; 73 | word-spacing: normal; 74 | word-break: normal; 75 | -moz-tab-size: 2; 76 | -o-tab-size: 2; 77 | tab-size: 2; 78 | -webkit-hyphens: none; 79 | -moz-hyphens: none; 80 | -ms-hyphens: none; 81 | hyphens: none; 82 | padding: 1em; 83 | margin: .5em 0; 84 | background-color: #f6f6f6; 85 | } 86 | .highlight-line { 87 | display: block; 88 | padding: 0.125em 1em; 89 | text-decoration: none; /* override del, ins, mark defaults */ 90 | color: inherit; /* override del, ins, mark defaults */ 91 | } 92 | 93 | /* allow highlighting empty lines */ 94 | .highlight-line:empty:before { 95 | content: " "; 96 | } 97 | /* avoid double line breaks when using display: block; */ 98 | .highlight-line + br { 99 | display: none; 100 | } 101 | 102 | .highlight-line-isdir { 103 | color: #b0b0b0; 104 | background-color: #222; 105 | } 106 | .highlight-line-active { 107 | background-color: #444; 108 | background-color: hsla(0, 0%, 27%, .8); 109 | } 110 | .highlight-line-add { 111 | background-color: #45844b; 112 | } 113 | .highlight-line-remove { 114 | background-color: #902f2f; 115 | } 116 | 117 | /* Header */ 118 | .home { 119 | padding: 0 1rem; 120 | float: left; 121 | margin: 1rem 0; /* 16px /16 */ 122 | font-size: 1em; /* 16px /16 */ 123 | } 124 | .home :link:not(:hover) { 125 | text-decoration: none; 126 | } 127 | 128 | /* Nav */ 129 | .nav { 130 | padding: 0; 131 | list-style: none; 132 | float: left; 133 | margin-left: 1em; 134 | } 135 | .nav-item { 136 | display: inline-block; 137 | margin-right: 1em; 138 | } 139 | .nav-item a[href]:not(:hover) { 140 | text-decoration: none; 141 | } 142 | .nav-item-active { 143 | font-weight: 700; 144 | text-decoration: underline; 145 | } 146 | 147 | /* Posts list */ 148 | .postlist { 149 | list-style: none; 150 | padding: 0; 151 | } 152 | .postlist-item { 153 | counter-increment: start-from -1; 154 | } 155 | .postlist-item:before { 156 | display: inline-block; 157 | pointer-events: none; 158 | content: "" counter(start-from, decimal-leading-zero) ". "; 159 | line-height: 100%; 160 | text-align: right; 161 | } 162 | .postlist-date, 163 | .postlist-item:before { 164 | font-size: 0.8125em; /* 13px /16 */ 165 | color: var(--darkgray); 166 | } 167 | .postlist-date { 168 | word-spacing: -0.5px; 169 | } 170 | .postlist-link { 171 | display: inline-block; 172 | padding: 0.25em 0.1875em; /* 4px 3px /16 */ 173 | } 174 | .postlist-item-active .postlist-link { 175 | font-weight: bold; 176 | } 177 | .tmpl-home .postlist-link { 178 | font-size: 1.1875em; /* 19px /16 */ 179 | font-weight: 700; 180 | } 181 | 182 | 183 | /* Tags */ 184 | .post-tag { 185 | display: inline-block; 186 | vertical-align: text-top; 187 | text-transform: uppercase; 188 | font-size: 0.625em; /* 10px /16 */ 189 | padding: 2px 4px; 190 | margin-left: 0.8em; /* 8px /10 */ 191 | background-color: var(--red); 192 | color: var(--white); 193 | border-radius: 0.25em; /* 3px /12 */ 194 | text-decoration: none; 195 | } 196 | a[href].post-tag, 197 | a[href].post-tag:visited { 198 | color: #fff; 199 | } 200 | 201 | /* Warning */ 202 | .warning { 203 | background-color: #ffc; 204 | padding: 1em 0.625em; /* 16px 10px /16 */ 205 | } 206 | .warning ol:only-child { 207 | margin: 0; 208 | } 209 | 210 | /* Direct Links / Markdown Headers */ 211 | .direct-link { 212 | font-family: sans-serif; 213 | text-decoration: none; 214 | font-style: normal; 215 | margin-left: .1em; 216 | } 217 | a[href].direct-link, 218 | a[href].direct-link:visited { 219 | color: transparent; 220 | } 221 | a[href].direct-link:focus, 222 | a[href].direct-link:focus:visited, 223 | :hover > a[href].direct-link, 224 | :hover > a[href].direct-link:visited { 225 | color: #aaa; 226 | } 227 | --------------------------------------------------------------------------------