A guide to understanding how static assets are served in Frappe Framework.
Static files are served from the
frappe-bench/sites/assets folder. When you
set up frappe for production deployment, nginx serves this folder directly. All
static file URLs always start with
/assets. A file at the location
frappe-bench/sites/assets/hero.png is accessible publicly via the URL
Every app has its own
public folder which can be used to serve static assets.
This folder is symlinked to
frappe-bench/sites/assets/[appname]. Here is the
tree command on the assets folder.
$ tree sites/assets -L 1
├── erpnext -> ~/frappe-bench/apps/erpnext/erpnext/public
└── frappe -> ~/frappe-bench/apps/frappe/frappe/public
This means if there is file at
[appname]/public/images/favicon.png, then it
also exists as a symlink at
assets/[appname]/images/favicon.png and is
accessible publicly via the URL
Bundled Assets are generated at
assets/[appname]/dist/css. Hence, they are
accessible via the URL
In addition to static files provided by apps, each site can have its own static files that might come from user uploads or site backups.
Files uploaded by user that are public are stored at
frappe-bench/sites/[sitename]/public/files. A file stored at
frappe-bench/sites/[sitename]/public/files/profile.png is accessible publicly
via the URL
Files uploaded by user that are private are stored at
frappe-bench/sites/[sitename]/private/files. A file stored at
frappe-bench/sites/[sitename]/private/files/profile.png is accessible via the
/private/files/profile.png. Private files are accessible only when the
user is authorized to view them.
Any local backups that are generated for the site are stored as
It is accessible via the URL
/backups/20210502_182223-[sitename]-database.sql.gz and only when the user is
authorized to download them.
Here is the output of the
$ ls -l sites/site1.test/private/backups
-rw-r--r-- 1 farisansari staff 2429268 May 2 18:22 20210502_182223-site1_test-database.sql.gz
-rw-r--r-- 1 farisansari staff 278 May 2 18:22 20210502_182223-site1_test-site_config_backup.json