Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (15 sloc) 1.05 KB
name sort
Static files

Static Files

Go already has the built-in http.ServeFile package to serve static files. Beego made a wrapper for it. To register static files use:

  • The first parameter is the url path
  • The second parameter is the static file directory path. (relative to the application directory)

Beego supports multiple static file directories:


With the above settings, request /images/login/login.png will find application_path/images/login/login.png and request /static/img/logo.png will find public/img/logo.png file.

By default Beego will check if the file exists, if not it will return a 404 page. If the request is for index.html, because http.ServeFile will redirect and doesn't display this page by default, you can set beego.BConfig.WebConfig.DirectoryIndex = true to show index.html page. If this is enabled, users can see the file list while visit the directory.

You can’t perform that action at this time.