| name | hf-static-space-deployer |
| description | Deploy general static websites and frontend apps to Hugging Face Spaces using `sdk: static`. Use when the user wants to host HTML/CSS/JS sites or built SPA frontends (React, Vite, Svelte, Vue, etc.) on Spaces for convenient sharing. Include setup for README YAML metadata (`app_file`, optional `app_build_command`), deployment via `hf` CLI or Python API, GitHub Actions sync, and static-Space troubleshooting. |
HF Static Space Deployer
Deploy static web content to Hugging Face Spaces in a repeatable way.
Choose the correct deployment mode
Use this skill when the app is static output.
-
Plain static files (no build step)
index.html + CSS/JS files committed directly.
- Use
sdk: static and app_file: index.html.
-
Build-first static app
- Framework source (React/Vite/Svelte/Vue/etc.) requires build.
- Use
sdk: static, app_build_command, and app_file pointing to built HTML (for example dist/index.html).
-
Do not use this skill when server-side runtime is required
- If the app needs a backend process, custom server routes, or non-static runtime behavior, use Docker Spaces instead.
Minimum required repo structure
At minimum, ensure:
README.md with YAML metadata block (includes sdk: static).
- App entry HTML referenced by
app_file.
- Any source/build files needed for build (if using
app_build_command).
See templates in:
Standard workflow
- Authenticate with Hugging Face.
- Create Space as
repo_type=space and space_sdk=static.
- Upload project files.
- Wait for build/startup.
- Validate app URL and behavior.
Use exact commands from:
Deployment quality checks
After upload/build, verify:
- Space build succeeds.
app_file exists at expected path.
- Site loads at the Space URL.
- Asset paths resolve correctly (no broken CSS/JS).
- If SPA:
- hash routing works directly; history routing may need fallback strategy.
- If query/hash syncing with parent page is required, use Spaces postMessage pattern.
See:
Security and platform caveats
- Static Spaces run inside an iframe on
huggingface.co/spaces/....
- For static Spaces, variables/secrets are available to browser JS through
window.huggingface.variables.
- Do not treat static frontend variables as confidential server-only secrets.
- Cookie behavior can differ from first-party hosting due to iframe constraints.
Use:
CI/CD guidance
Prefer one of:
- Push directly with
hf upload.
- Mirror from GitHub with a GitHub Action that pushes to the Space repo.
Use templates from:
Local tooling bundled with this skill
scripts/scaffold_static_space.py: generate a README.md metadata block and optional GitHub Action workflow.
scripts/validate_static_space.py: validate local projects and/or existing deployed Spaces (for example --space-id evalstate/foo).
Output expectations
When helping a user, always produce:
- Final
README.md YAML block.
- Exact deploy command sequence.
- Suggested CI option (manual or GitHub Actions).
- Post-deploy validation checklist.
- Troubleshooting steps tailored to framework/output path.