> For the complete documentation index, see [llms.txt](https://docs.pandastack.io/v1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pandastack.io/v1/getting-started/platform/static-website.md).

# Static Website

This guide walks you through deploying and managing static websites on PandaStack Platform.

## Features

### Basic Features

* Static file hosting
* Custom domains
* SSL/TLS certificates
* Auto deployment from Git
* Build automation
* Environment variables

### Advanced Features

1. Custom HTTP Headers
   * Cache control
   * Security headers
   * Custom response headers
   * Path-specific headers
2. URL Management
   * URL redirects
   * URL rewrites
   * Wildcard patterns
   * Rule prioritization

## Deployment Steps

### 1. Connect Repository

1. Choose Git Provider:
   * GitHub
   * GitLab
   * Bitbucket
2. Select Repository:
   * Choose repository
   * Select branch
   * Configure access

### 2. Configure Build

1. Basic Settings:
   * Project name
   * Repository branch
   * Auto-deploy settings
2. Build Configuration:

   ```bash
   # Base Directory (Optional)
   ./frontend

   # Build Command
   npm run build

   # Output Directory
   build/
   ```
3. Environment Variables:
   * Add key-value pairs
   * Import from .env file
   * Secure sensitive data

### 3. Deploy Website

1. Initial Deployment:
   * Automatic build
   * Asset optimization
   * SSL provisioning
2. Verify Deployment:
   * Check build logs
   * Test website
   * Monitor status

## URL Management

### Redirect Rules

```json
{
    "source": "/old-page",
    "destination": "/new-page",
    "type": "redirect"
}
```

### Rewrite Rules

```json
{
    "source": "/api/*",
    "destination": "/api/v2/*",
    "type": "rewrite"
}
```

### Rule Management

* Order rules by priority
* Move rules up/down
* Enable/disable rules
* Test rule patterns

## HTTP Headers

### Custom Headers

```json
{
    "name": "Cache-Control",
    "value": "public, max-age=3600"
}
```

### Common Use Cases

1. Cache Control:

   ```json
   {
       "name": "Cache-Control",
       "value": "public, max-age=3600"
   }
   ```
2. Security Headers:

   ```json
   {
       "name": "Content-Security-Policy",
       "value": "default-src 'self'"
   }
   ```
3. CORS Headers:

   ```json
   {
       "name": "Access-Control-Allow-Origin",
       "value": "*"
   }
   ```

## Environment Management

### Environment Variables

1. Direct Input:

   ```bash
   API_URL=https://api.example.com
   FEATURE_FLAG=true
   ```
2. File Import:

   ```env
   # .env file
   API_KEY=your-api-key
   DEBUG=false
   ```

### Secret Management

* Secure storage
* Environment separation
* Access control
* Version tracking

## Best Practices

### 1. Build Configuration

* Use proper base directory
* Optimize build command
* Configure output path
* Handle dependencies

### 2. URL Management

* Order rules properly
* Use specific patterns
* Test redirects
* Monitor traffic

### 3. Headers

* Set security headers
* Configure caching
* Use appropriate values
* Test header effects

### 4. Performance

* Optimize assets
* Configure caching
* Use CDN
* Monitor metrics

## Troubleshooting

### 1. Build Issues

* Check build command
* Verify dependencies
* Review build logs
* Check resource limits

### 2. URL Issues

* Test redirect rules
* Verify patterns
* Check rule order
* Monitor traffic

### 3. Header Issues

* Verify header syntax
* Test header effects
* Check conflicts
* Monitor responses

### 4. Performance Issues

* Review caching
* Check asset sizes
* Monitor load times
* Analyze metrics

## Security

### 1. SSL/TLS

* Automatic certificates
* Custom certificates
* Force HTTPS
* Security headers

### 2. Access Control

* Repository access
* Environment variables
* Secret management
* Role permissions

### 3. Headers

* Security headers
* CORS configuration
* Content security
* Frame options

## Monitoring

### 1. Build Status

* Build logs
* Deployment status
* Error tracking
* Performance metrics

### 2. Website Status

* Uptime monitoring
* Response times
* Error rates
* Traffic analysis

### 3. Security Status

* SSL monitoring
* Security headers
* Access logs
* Threat detection


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pandastack.io/v1/getting-started/platform/static-website.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
