docs icon indicating copy to clipboard operation
docs copied to clipboard

[add] Where do I put my Global Stuff? BaseLayout recommendation?

Open sarah11918 opened this issue 2 years ago • 2 comments

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.

sarah11918 avatar Sep 07 '22 16:09 sarah11918

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!

WintrCodes avatar Sep 30 '22 11:09 WintrCodes

Woo, @WintrCodes! Thanks for stepping up! 🙌

Please do feel free to go start scouting and doing some research, chat ppl up in Discord!

sarah11918 avatar Sep 30 '22 11:09 sarah11918

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.

delucis avatar Nov 03 '22 15:11 delucis

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

smithbm2316 avatar Nov 04 '22 22:11 smithbm2316

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).

Jutanium avatar Mar 16 '23 15:03 Jutanium

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)

WintrCodes avatar Mar 17 '23 14:03 WintrCodes

Closing as there hasn’t been much activity here. Still happy for anyone to PR an improvement if they like!

delucis avatar Jul 27 '23 14:07 delucis

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

mayank99 avatar Jul 27 '23 14:07 mayank99

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.

delucis avatar Jul 27 '23 17:07 delucis