docs
docs copied to clipboard
[add] Where do I put my Global Stuff? BaseLayout recommendation?
From @mayank99's observation in Discord:
i think it's not obvious from the docs where your "global stuff" lives. where do you import your global styles? what about fonts?
And @delucis's response:
Good call out. We vaguely mention "base layout" in a few places for the idea you have some component that takes care of common stuff (global CSS, fonts, SEO meta tags, etc) but don't necessarily show that as a pattern clearly.
This is actually something I want to understand personally, so once I've got that confirmed, I'd be happy to put this into the docs for others who may also be a bit confused/unsure about it.
Feel free to assign to me, and I'll have a chat with folks in the Discord for a 'best practice' approach!
Woo, @WintrCodes! Thanks for stepping up! 🙌
Please do feel free to go start scouting and doing some research, chat ppl up in Discord!
Hey @WintrCodes! Thanks for stepping up. It’s been a while so I unassigned, but would still love a contribution from you or anyone else!
For anyone who’s interested, this would be a great addition to the Layouts page.
I would be quite interested in taking this on! I am looking to find a needed contribution for either Astro or the Astro docs and would love to explore this. Let me see if I can do some digging in the Astro discord for a few other perspectives that might differ to how I've approached this in my own Astro tinkering, and I can try to get a first-draft/proof-of-concept for this written soon. Perhaps then I can send a link to the PR in the Astro discord where I can request feedback from the community! :smiley: Please feel free to assign this to me Astro docs team unless @WintrCodes is still interested in handling this
Pinging for freshness 💐
This shouldn't just say that you can add global tags to your base layout - it should also describe recommendations for what your global tags should be (meta
tags, favicon, etc).
I'm going to come back and take another look at this now I'm in a better headspace for it.
Will see what I can come up with. I'll probably look to get some input on things you want included when it comes to global tags (meta, favicon, and I guess anything that goes in the head
)
Closing as there hasn’t been much activity here. Still happy for anyone to PR an improvement if they like!
the problem might be that there isn't much guidance from Astro's side to even contribute.
"where do i put the global stuff?" "yeah this should be documented" "ok lets document it, but i still don't know where to put it"
personally, i've been creating a _global.astro
file and importing it into all my layouts (which are usually named _layout.astro
). i'm not sure if the _
prefix is officially recommended but it allows me to colocate these things right next to my routes
Yeah, it's hard because there's no right/wrong here really. Like to colocate? Use something like your underscore files. Prefer a dedicated folder each for layouts, style etc.? That's cool too! Should the file be .astro
or .ts
? Both are fine!
We have noticed people tend to interpret "soft" advice ("You might want to do X") as hard requirements. For example, we suggest people use src/assets/
for images, and are constantly clearing up confusion that actually you can also store images elsewhere too. So I don't know if our opinion is definitely helpful here.