Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/content/docs/en/basics/layouts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ We conventionally use the term "layout" for Astro components that provide common

But, there is nothing special about a layout component! They can [accept props](/en/basics/astro-components/#component-props) and [import and use other components](/en/basics/astro-components/#component-structure) like any other Astro component. They can include [UI frameworks components](/en/guides/framework-components/) and [client-side scripts](/en/guides/client-side-scripts/). They do not even have to provide a full page shell, and can instead be used as partial UI templates.

However, if a layout component does contain a page shell, its `<html>` element must be the parent of all other elements in the component. All [`<style>`](/en/guides/styling/#styling-in-astro) or [`<script>`](/en/guides/client-side-scripts/#using-script-in-astro) elements must be enclosed by the `<html>` tags.

Layout components are commonly placed in a `src/layouts` directory in your project for organization, but this is not a requirement; you can choose to place them anywhere in your project. You can even colocate layout components alongside your pages by [prefixing the layout names with `_`](/en/guides/routing/#excluding-pages).

## Sample Layout
Expand Down Expand Up @@ -43,6 +45,11 @@ const { title } = Astro.props;
</article>
<Footer />
</body>
<style>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SMRT! 🙌

h1 {
font-size: 2rem;
}
</style>
</html>
```

Expand Down