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: staticandapp_file: index.html.
Build-first static app
- Framework source (React/Vite/Svelte/Vue/etc.) requires build.
- Use
sdk: static,app_build_command, andapp_filepointing to built HTML (for exampledist/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.mdwith YAML metadata block (includessdk: static).- App entry HTML referenced by
app_file. - Any source/build files needed for build (if using
app_build_command).
See templates in:
- references/readme_templates.md
Standard workflow
- Authenticate with Hugging Face.
- Create Space as
repo_type=spaceandspace_sdk=static. - Upload project files.
- Wait for build/startup.
- Validate app URL and behavior.
Use exact commands from:
- references/deploy_workflows.md
Deployment quality checks
After upload/build, verify:
- Space build succeeds.
app_fileexists 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:
- references/troubleshooting.md
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:
- references/security_and_platform_notes.md
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:
- references/deploy_workflows.md
Local tooling bundled with this skill
scripts/scaffold_static_space.py: generate aREADME.mdmetadata 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.mdYAML block. - Exact deploy command sequence.
- Suggested CI option (manual or GitHub Actions).
- Post-deploy validation checklist.
- Troubleshooting steps tailored to framework/output path.