Skip to content

将你的 Astro 站点部署到 Heroku

Heroku 是一个平台即服务,用于在云中构建、运行和管理现代应用。你可以使用本指南将 Astro 站点部署到 Heroku。

¥Heroku is a platform-as-a-service for building, running, and managing modern apps in the cloud. You can deploy an Astro site to Heroku using this guide.

¥How to deploy

  1. Install the Heroku CLI.

  2. Create a Heroku account by signing up.

  3. Run heroku login and fill in your Heroku credentials:

    终端窗口
    $ heroku login
  4. Create a file called static.json in the root of your project with the below content:

    static.json
    {
    "root": "./dist"
    }

    This is the configuration of your site; read more at heroku-buildpack-static.

  5. Set up your Heroku git remote:

    终端窗口
    # version change
    $ git init
    $ git add .
    $ git commit -m "My site ready for deployment."
    # creates a new app with a specified name
    $ heroku apps:create example
    # set buildpack for static sites
    $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-static.git
  6. Deploy your site:

    终端窗口
    # publish site
    $ git push heroku master
    # opens a browser to view the Dashboard version of Heroku CI
    $ heroku open

更多部署指南

Astro 中文网 - 粤ICP备13048890号