---
schema_version: "1"
id: 851e62e278476b82105519c0648ec38b5a92c1b02587fb7885668ecbe150b8d7
title: template generate static-resource
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfclireference/guides/template/cli_reference_template_generate_static-resource.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_template_generate_static-resource.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0598c86e76132a9a0861dea877c37ab2f1bab8528abae30020ebeaeb690b385d
products:
  - Salesforce CLI Command Reference
  - salesforcedx
---
<!-- prettier-ignore-start -->

# template generate static-resource

Generate a static resource.

## Description for template generate static-resource

Generates the metadata resource file in the specified directory or the current working directory. Static resource files must be contained in a parent directory called "staticresources" in your package directory. Either run this command from an existing directory of this name, or use the --output-dir flag to create one or point to an existing one.

## Aliases for template generate static-resource

`force:staticresource:create`

`static-resource:generate`

## Flags

| Flag Name (Long) | Flag Name (Short) | Description |
|------------------|-------------------|-------------|
| <code>&#8209;&#8209;api&#8209;version</code> | N/A | **Type:** Value<br><br>Override the api version used for api requests made by this command |
| <code>&#8209;&#8209;flags&#8209;dir</code> | N/A | **Type:** Value<br><br>Import flag values from a directory. |
| <code>&#8209;&#8209;json</code> | N/A | **Type:** Boolean<br><br>Format output as json. |
| <code>&#8209;&#8209;name</code> | <code>&#8209;n</code> | **Type:** Value<br>**Required**<br><br>Name of the generated static resource.<br><br>This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. |
| <code>&#8209;&#8209;output&#8209;dir</code> | <code>&#8209;d</code> | **Type:** Value<br>**Default value:** `.`<br><br>Directory for saving the created files.<br><br>The location can be an absolute path or relative to the current working directory. The default is the current directory. |
| <code>&#8209;&#8209;type</code> | N/A | **Type:** Value<br>**Default value:** `application/zip`<br><br>Content type (mime type) of the generated static resource.<br><br>Must be a valid MIME type such as application/json, application/javascript, application/zip, text/plain, text/css, etc. |

## Examples for template generate static-resource

Generate the metadata file for a static resource called MyResource in the current directory:

```shell
sf template generate static-resource --name MyResource
```

Similar to previous example, but specifies a MIME type of application/json:

```shell
sf template generate static-resource --name MyResource --type application/json
```

Generate the resource file in the "force-app/main/default/staticresources" directory:

```shell
sf template generate static-resource --name MyResource --output-dir force-app/main/default/staticresources
```
<!-- prettier-ignore-end -->
