Custom URL for assets folder in Jekyll

1.2k views Asked by At

I currently have a Jekyll project with this structure:

├── _config.yml
├── assets
|   ├── js
|   ├── css
|   └── images

And my _config.yml looks like:

.
.
lang: en
destination: _site/en
.
.

So, when building the project all the site is inside the _site/en/ folder, this includes de assets folder with all my static assets (Images, css, js, etc).

Is there a way to build the page configuring a custom destination for the assets folder?

├── _config.yml
├── _site
|   ├── en
|   └── assets

I tried by adding this to my _config.yml (having installed jekyll-assets) without lucky:

assets:
  dirname: assets
  baseurl: /assets/
  sources:
    - assets
2

There are 2 answers

0
ccamacho On BEST ANSWER

At the end, I'm building my site in several jekyll build executions. So, for me the simplest way of doing this is by excluding the assets folder for each language build and simply run a 'cp -a' of the assets folder to the _site/ folder. In this case, I avoid using another plugin and simply copy the files you need.

1
Jack Leahy On

Since the root folder is now: /_site/en/ you need to step down a level.

Try using this:

../assets/

This will step down a directory out of /en/.