How to Manage Static Sites in App Platform
Validated on 24 Feb 2024 • Last edited on 5 Mar 2026
App Platform is a fully managed Platform-as-a-Service (PaaS) that deploys applications from Git repositories or container images. It automatically builds, deploys, and scales components while handling all underlying infrastructure.
You can add a static site as an additional component of your app at any time by updating the app.
Add a Static Site to an App Using Automation
You can add a static site to an app using the CLI’s app update command or the API’s app update endpoint. To add a static site, update the app spec with the static site’s specifications and submit the spec using the following command or endpoint.
Add a Static Site Using the Control Panel
Go to the Apps page of the DigitalOcean Control Panel and select your app. Click Add components, then choose Create resources from source code to add a static site.
On the Add resources screen:
- Select your deployment source, either a Git repository or a container image. If you have not previously created an app on App Platform, the repository service may prompt you to provide DigitalOcean with read permissions to your account.
- If using a Git repository, choose a branch to deploy from. By default, App Platform builds from the repository's root. If your code lives in a subdirectory (for example, in a monorepo), set the source directory to match.
- Clear the Autodeploy checkbox if you want to stop automatic redeploys when the repository changes.
- Click Next.
App Platform retrieves your code, analyzes your repository, and automatically selects the appropriate runtime (such as Node or Ruby). If you need to override this behavior, upload a Dockerfile to your branch and restart the creation process.
Configure Resource Settings
The Resource settings table displays the configuration settings, some of which the detection system auto-fills.
You can configure the following settings:
-
Name: A unique name for the component.
-
Resource type: The type of component to deploy (web service, static site, worker, or job).
-
Branch: The branch to deploy from. You can enable automatic redeploys when changes are made to this branch.
-
Output Directory: For static sites only. An optional path to where the build assets are located, relative to the build context. If not set, App Platform automatically scans for these directory names:
_static,dist,public,build. -
HTTP request routes: For web services and static sites only. The URL path where the app can be accessed, such as
your-app-v3cl4.ondigitalocean.app/api. If not specified, the app is accessible from the provided hostname's root. -
Environment variables: Key-value pairs available to your app at runtime that let you keep configuration separate from application code. Use them to provide secrets, API keys, and other external settings, such as connection details for an external database.
Set App-Level Environment Variables
App-level environment variables are available to all components in your app. Use them for shared configuration, secrets, API keys, or other values your app needs at build time or runtime.
To set app-level environment variables:
- Click Edit in the App-level environment variables section.
- Click Add environment variable, type a key and value, then select a scope.
- Select Encrypt to obscure the value in build, deployment, and application logs.
For dynamic, app-specific variables that your app can reference, see Use Bindable Variables.
Review and Deploy
Review the configuration and pricing details in the Summary section, then click Add resources.
App Platform creates the component with the selected settings and deploys it automatically. You can view or update the component's configuration on the Settings page.
Configure a Static Site
Go to the Apps page, select your app, then click the Settings tab. Select the static site you want to edit.
Click Edit beside a setting you want to change, then click Save.
When an error occurs on the static site, App Platform displays an error document. You can specify a custom error document. Click Edit in the Custom Pages section.
Select one of the following options:
-
Error: Specify a document to serve when an error occurs.
-
Catchall: Specify a catch-all document that the site uses to redirect requests to pages that are not found on the site.
Enter the name of the error or catch-all document in the Page Name field and click Save. The .html file must be in your repository for App Platform to use it in the build. App Platform uses a default document if you do not provide one. For static sites that have JavaScript-based client side routing, you can specify index.html as the catch-all document.
Destroy a Static Site
Go to the Apps page, select your app, then click the Settings tab. Select the static site you want to destroy.
At the bottom of the page, click Destroy Component. Enter the static site's name to confirm, then click Destroy.