hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

static-files.md (2467B)

    1 ---
    2 title: Static Files
    3 description: "Files that get served **statically** (as-is, no modification) on the site root."
    4 date: 2017-11-18
    5 categories: [content management]
    6 keywords: [source, directories]
    7 menu:
    8   docs:
    9     parent: "content-management"
   10     weight: 130
   11 weight: 130	#rem
   12 aliases: [/static-files]
   13 toc: true
   14 ---
   15 
   16 By default, the `static/` directory in the site project is used for
   17 all **static files** (e.g. stylesheets, JavaScript, images). The static files are served on the site root path (eg. if you have the file `static/image.png` you can access it using `http://{server-url}/image.png`, to include it in a document you can use `![Example image](/image.png) )`.
   18 
   19 Hugo can be configured to look into a different directory, or even
   20 **multiple directories** for such static files by configuring the
   21 `staticDir` parameter in the [site config][]. All the files in all the
   22 static directories will form a union filesystem.
   23 
   24 This union filesystem will be served from your site root. So a file
   25 `<SITE PROJECT>/static/me.png` will be accessible as
   26 `<MY_BASEURL>/me.png`.
   27 
   28 Here's an example of setting `staticDir` and `staticDir2` for a
   29 multi-language site:
   30 
   31 {{< code-toggle copy="false" file="config" >}}
   32 staticDir = ["static1", "static2"]
   33 
   34 [languages]
   35 [languages.en]
   36 staticDir2 = "static_en"
   37 baseURL = "https://example.com"
   38 languageName = "English"
   39 weight = 2
   40 title = "In English"
   41 [languages.no]
   42 staticDir = ["staticDir_override", "static_no"]
   43 baseURL = "https://example.no"
   44 languageName = "Norsk"
   45 weight = 1
   46 title = "På norsk"
   47 {{</ code-toggle >}}
   48 
   49 In the above, with no theme used:
   50 
   51 - The English site will get its static files as a union of "static1",
   52   "static2" and "static_en". On file duplicates, the right-most
   53   version will win.
   54 - The Norwegian site will get its static files as a union of
   55   "staticDir_override" and "static_no".
   56 
   57 Note 1
   58 : The **2** (can be a number between 0 and 10) in `staticDir2` is
   59   added to tell Hugo that you want to **add** this directory to the
   60   global set of static directories defined using `staticDir`. Using
   61   `staticDir` on the language level would replace the global value (as
   62   can be seen in the Norwegian site case).
   63 
   64 Note 2
   65 : The example above is a [multihost setup][]. In a regular setup, all
   66   the static directories will be available to all sites.
   67 
   68 
   69 [site config]: /getting-started/configuration/#all-configuration-settings
   70 [multihost setup]: /content-management/multilingual/#configure-multilingual-multihost