You'll build a site that connects multiple pages together with a reusable navigation component.
It'll have the following features:
Command
+ Shift
+ A
on MacOS or Ctrl
+ Shift
+ A
on Windows)Ctrl
+ `
npm run dev
Now you're ready to get coding!
Creating new pages in Svelte is as easy as creating a new folder in your routes
folder. We're going to create a second page so that you can practise reusing components, and learn how to create a reusable nav menu.
routes
folder, and call it about-me
about-me
called +page.svelte
import
and add your Header
and Footer
components to the pagemain
section between the Header
and Footer
with some information about yourself<script>
import ComponentName from '$lib/ComponentName.svelte'
</script>
<ComponentName />
Navigation menus can quickly become unwieldy when your site gets large enough - update one page name and you have to go through every nav menu and update them accordingly.
In modern websites, developers create one reusable nav menu.
lib
folder, and call it Nav.svelte
<nav>
<a href="/"> Home </a>
<a href="/about-me"> About Me </a>
</nav>
import
and add your Nav
component to both pagesChange your nav
to personalise your web page.
text-align: center;
text-decoration: line-through;
text-transform: uppercase;
text-shadow: 2px 2px orange;
Congratulations, the second iteration of your web page is complete.
You've taken the code provided and customised it to create your unique site.
Along the way, you've learnt about these parts of coding.
(➕ means new things in this project)
Svelte
components
for reusable blocks of codeFrom here, you can take your page further, if you like, by adding images from your summer, links to your social media, YouTube channel, blog, or whatever you like.