Skip to content
Source
Sign inSign up

Host your site's files

Code and repositories / Assets

Host your site's files

Your site needs images, videos and fonts, but every version that you commit stays in the git history of each clone. Assets keep these files outside git, and give each file a URL for your site.

4 min read

If you bundle the files instead, your build grows with each file. An asset is never in a commit or a clone.

You need write access to the repository.

1. Open the Assets tab

Open the repository, then the Assets tab (/@<owner>/<repo>/assets).

2. Upload a file

Drop a file on Drop files here to upload them, or click Choose files. The file goes into the folder that is open.

Each row of the list shows a preview of the file, its size and its version.

The Assets tab of alice/site, open at the images folder: the upload area, then hero.png at version 2 of 2, logo.svg and og.png, each with a preview, and the Who can open them card

Note

A file is at most 100 MiB by default. What you can upload lists the other limits.

3. Copy the URL of the file

Click the name of the file. A dialog opens with the URL of the file. Click Copy URL.

The dialog also shows the file: an image, a player for a video or audio, or a PDF in the PDF viewer of your browser. Open the PDF opens a PDF in a new tab.

4. Use the URL in your code

Put the URL where you put the path of a local file:

<img src="https://forge.example/@acme/site/assets/images/hero.png" alt="The dashboard of the app" />

<video src="https://forge.example/@acme/site/assets/videos/launch.mp4" controls></video>
@font-face {
  font-family: 'Inter';
  src: url('https://forge.example/@acme/site/assets/fonts/Inter.woff2') format('woff2');
}
  • The URL always serves the current version of the file. Browsers cache it for 1 minute.
  • A public image, video, audio file or download can come from a copy in Europe or Asia, near the person who opens it: the URL then answers with a redirect to that copy. The forge turns this on for the whole site.
  • Add ?v=<n> to serve one version that never changes. Versions and caching shows when to use each URL.
  • Video players can jump to any point, because the forge serves parts of a file on request.
  • When the assets are public, other sites can load them too, fonts included. Who can see your assets says when they are public, and how to hide a draft.

Done

Your file is on the forge, and your site shows it from its URL. Your git history did not change.

Next, upload from a build script, the src CLI or a coding agent. To show an image when people share a link to your repository on X, Slack or Discord, see Show a good link preview.

Reference

What you can upload

  • A file is at most 100 MiB by default. A site admin can change this limit for the whole forge: see Set the limits of the site.
  • The assets of one repository hold at most 10 GiB. The same bytes count once, even at two paths. Old versions count until you delete them.
  • Images (SVG too), video, audio, fonts, PDF, JSON, plain text, CSV, CSS and JavaScript open with their own type. Any other file, HTML too, downloads as an attachment.
  • The forge serves every asset in a sandbox, so no asset can run as a page of the forge.
  • A fork starts with no assets.

Files attached to issues and comments

People add screenshots and videos to issues, pull requests, comments and Community posts. Each file goes to the folder attachments/ of the Assets tab, and the text links to it.

  • Anyone who can comment can attach an image (10 MiB at most) or a video (100 MiB at most). Write access is not necessary.
  • The name of each file is the SHA-256 of its bytes. The same file attached two times is one asset.
  • The files of people without write access stay hidden until their text shows. Who can see your assets explains it.
  • Attachments count toward the 10 GiB of the repository. Hide or delete them as you do other assets.

Add images and videos to issues and comments shows how to attach a file.

Package previews

CI publishes package previews into the folder package-previews/. The forge manages that folder, and deletes each preview 3 to 4 days after its pull request closes. See When previews are deleted.