Skip to content
FunCoding

deploy-to-hf-spaces

Deploy the article to a Hugging Face Space. Use when the user asks to deploy, push, publish, or update their Space on Hugging Face.

Star
592
Category
Ops & cloud
License
Apache-2.0
Last commit
Dec 2, 2026

content/articles/rl-environments-guide/.ai/skills/deploy-to-hf-spaces/SKILL.md

View on GitHub

Deploy to Hugging Face Spaces

Guide for deploying and updating a research article on Hugging Face Spaces.

Prerequisites

  • A Hugging Face account with an SSH key configured ([email protected])
  • Or HTTPS access with huggingface-cli login

First deployment

1. Create the Space

Via CLI:

huggingface-cli repo create <username>/<space-name> --repo-type space --space_sdk docker

Or manually at https://huggingface.co/new-space (select Docker SDK).

2. Add the remote

git remote add space [email protected]:spaces/<username>/<space-name>

3. Push

git push space main

The Space will build automatically using the included Dockerfile and nginx.conf. Build typically takes 3-5 minutes.

Updating an existing Space

git add -A
git commit -m "feat: describe your changes"
git push space main

Force push (when needed)

If the Space history has diverged (e.g., after a factory reset or manual edit on HF):

git push space main --force

Verifying deployment

  1. Go to https://huggingface.co/spaces/<username>/<space-name>
  2. Check the Factory tab for build logs
  3. The build is complete when status shows "Running"
  4. If the page looks stale, append ?v=<timestamp> to the URL to bypass CDN cache

Cache busting

Hugging Face Spaces aggressively cache static assets. If changes don't appear after a successful build:

  1. Check that the CSS bundle hash has changed (view page source, look for /_astro/*.css)
  2. If unchanged, the build used a stale cache - push an empty commit to force rebuild:
    git commit --allow-empty -m "chore: trigger rebuild"
    git push space main
    
  3. Wait for the new build to complete before checking again

README tag (critical)

The README.md YAML frontmatter must contain:

tags:
  - research-article-template

NEVER remove this tag. It is used by the Research Article Gallery to list the article. Without it, the Space becomes invisible in the gallery.

README frontmatter reference

---
title: "Article Title"
emoji: 📝
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 8080
header: mini
pinned: false
tags:
  - research-article-template
---
FieldDescription
titleDisplayed in the Space card
emojiEmoji shown on the Space card
colorFrom / colorToGradient colors for the card header
sdk: dockerRequired - uses the Dockerfile for build
app_port: 8080Required - nginx serves on 8080
header: miniCompact header (recommended for articles)
tagsMust include research-article-template

Troubleshooting

ProblemSolution
Build failsCheck build logs in the Factory tab. Common issue: missing dependencies in package.json
CSS/layout looks wrongCache issue - force rebuild with empty commit
Images not showingIf using Git LFS, ensure LFS files are pushed. Otherwise check image paths
PDF not generatedPlaywright is included in Docker build; check build logs for errors
Space shows old contentWait 2-3 min after build completes for CDN propagation, then hard refresh

Similar Skills

Featured

internal-comms

Write internal communications following company formats, including status reports, leadership updates, and newsletters.

ANanthropics/skills203k3,265 new stars in the last 7 days

canary

GAgarrytan/gstack143k598 new stars in the last 7 days

Featured

shipping-and-launch

A pre-launch checklist covering monitoring, staged rollouts and rollback plans.

ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days

observability-and-instrumentation

ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days

paperclip-board

PApaperclipai/paperclip119k1,966 new stars in the last 7 days

ruview-configure

RUruvnet/RuView106k739 new stars in the last 7 days