Create your first Astro page
本頁內容尚未翻譯。
Now that you know that .astro files are responsible for pages on your website, it’s time to create one!
準備好……
- Create two new pages on your website: About and Blog
- Add navigation links to your pages
- Deploy an updated version of your website to the web
Create a new .astro file
Section titled “Create a new .astro file”-
In the files pane of your code editor, navigate to the folder
src/pages/where you will see the existing fileindex.astro -
In that same folder, create a new file named
about.astro. -
Copy, or retype the contents of
index.astrointo your newabout.astrofile.Your editor might show a solid white circle on the tab label for this file. This means that the file is not yet saved. Under the File menu in VS Code, enable “Auto Save” and you should no longer need to save any files manually.
-
Add
/aboutto the end of your website preview’s URL in the address bar and check that you can see a page load there. (e.g.http://localhost:4321/about)
Right now, your “About” page should look exactly the same as the first page, but we’re going to change that!
Edit your page
Section titled “Edit your page”Edit the HTML content to make this page about you.
To change or add more content to your About page, add more HTML element tags containing content. You can copy and paste the HTML code below between the existing <body></body> tags, or create your own.
<body> <h1>My Astro Site</h1> <h1>About Me</h1> <h2>... and my new Astro site!</h2>
<p>I am working through Astro's introductory tutorial. This is the second page on my website, and it's the first one I built myself!</p>
<p>This site will update as I complete more of the tutorial, so keep checking back and see how my journey is going!</p></body>