What if you could change your website's header once and see it update everywhere instantly?
Why Layout files (+layout.svelte)? - Purpose & Use Cases
Imagine building a website where every page needs the same header, footer, and navigation menu. You have to copy and paste this code into every single page file.
Manually repeating layout code is tiring and risky. If you want to change the header, you must update every page separately. This wastes time and can cause mistakes or inconsistencies.
Layout files like +layout.svelte let you write shared page structure once. All pages inside that folder automatically use this layout, so updates happen in one place and apply everywhere.
<header>Site header</header> <nav>Menu</nav> <main>Page content</main> <footer>Site footer</footer>
<!-- +layout.svelte --> <header>Site header</header> <nav>Menu</nav> <slot></slot> <footer>Site footer</footer>
This makes building consistent, maintainable websites easy and fast by sharing common page parts automatically.
Think of a blog where every post has the same top menu and footer. Using +layout.svelte, you write that once and focus only on the unique post content for each page.
Layout files avoid repeating shared page code.
They let you update common parts in one place.
This saves time and reduces errors in your site.