Black | Autistic | 22 | Enjoyer of things | Huge blue rat enjoyer | Beginner (occasional) artist| Aspiring Game Dev and VA


A certain dumb bird site:
twitter.com/Geeky_Jay9

i'm currently working on migrating my site (which is currently just the front page) to eleventy. and the thing about the site is that i'm using the one that's from the sadgrl's layout maker. and i am struggling to know on which line of code goes where on both the index.md and base.njk.

if anyone knows the answer to this, please tell me and thank you.

(also sorry for asking so much, i am a complete beginner at this.)


You must log in to comment.

in reply to @geeky-jay's post:

So generally, you want to put all the "outer" html stuff that you want on multiple pages and that you don't want to have to type out each time in your .njk

So that would be stuff like the < html >, < head >, < body >

And then generally, all of your "inner" content would go in the .md, so all the stuff you actually want to print on your page.

If that didn't make sense, I found this tutorial super helpful when I was getting set up on eleventy!

so from my understanding + my idea of what i want the site template to be,

  • have the main stuff like the header, main nav bar (for the different pages), and footer in the .njk file
  • while having everything else that i want to stay in the front page like the other nav bars (like the updates, status, and the guestbook/chatbox) and others in the .md

is that correct?

index.njk file:

<body>

{{ content | safe }}

</body>

index.md file:

---
layout: index.njk 
---
Hello World!

In this example, the "Hello World!" from your .md file will be inserted between the body tags of the final index.html file once 11ty builds it.

Yeah so basically this lets you keep your html "wrapper" in a template (.njk) file, and then when you invoke that template with the layout tag in your markdown frontmatter, all the content in your markdown file (the stuff you want people to see) will be rendered into html using that wrapper. Which lets you write out all the html garbage once, and then just write out a bunch of page content super quickly. This also helps when you need to change some piece of your html - you only have to change it in one place (the template file), rather than on every page.
Really hope this makes sense!