Przejdź do głównej zawartości

Create your first Astro project

Ta treść nie jest jeszcze dostępna w Twoim języku.

Przygotuj się na…

  • Run the create astro setup wizard to create a new Astro project
  • Start the Astro server in development (dev) mode
  • View a live preview of your website in your browser

The preferred way to create a new Astro site is through our create astro setup wizard.

  1. In the command line of your terminal, run the following command using your preferred package manager:

    Terminal window
    # create a new project with npm
    npm create astro@latest -- --template minimal
  2. Confirm y to install create-astro

  3. When the prompt asks you where to create the project, type in the name of a folder to create a new directory for your project, e.g. ./tutorial

  4. When the prompt asks you whether or not to install dependencies, type or select y.

  5. When the prompt asks you whether or not to initialize a new git repository, type or select y.

When the install wizard is complete, you no longer need this terminal. You can now open VS Code to continue.

  1. Open VS Code. You will be prompted to open a folder. Choose the folder that you created during the setup wizard.

  2. If this is your first time opening an Astro project, you should see a notification asking if you would like to install recommended extensions. Click to see the recommended extensions, and choose the Astro language support extension. This will provide syntax highlighting and autocompletions for your Astro code.

  3. Make sure the terminal is visible and that you can see the command prompt, such as:

    Terminal window
    user@machine:~/tutorial$

You can now use the terminal built right into this window, instead of your computer’s Terminal app, for the rest of this tutorial.

In order to preview your project files as a website while you work, you will need Astro to be running in development (dev) mode.

  1. Run the command to start the Astro dev server by typing into VS Code’s terminal:

    Terminal window
    npm run dev

    Now you should see confirmation in the terminal that Astro is running in dev mode. 🚀

View a preview of your website

Section titled View a preview of your website

Your project files contain all the code necessary to display an Astro website, but the browser is responsible for displaying your code as web pages.

  1. Click on the localhost link in your terminal window to see a live preview of your new Astro website!

    (Astro uses http://localhost:4321 by default if port 4321 is available.)

    Here’s what the Astro “Empty Project” starter website should look like in the browser preview:

    A blank white page with the word Astro at the top.

Pomóż nam

Jak chcesz ją przekazać?

Otwórz Issue na GitHubie

Najszybszy sposób na powiadomienie nas o problemie.

Społeczność