How can I setup Jekyll for a blog with a large image directory, so as to avoid duplicating that directory in the generated site?

Viewed 4887

I'm considering Jekyll for a site I'm putting together that will be a blog with lots of images (and other larg-ish media files). It's easy enough to to make a directory for images and then link to them as needed in the posts. But, as I understand it, when the site is generated, all the image data will be duplicated into the generated _site directory that holds the static files. Each time the site is generated the _site directory is emptied, and repopulated with the static version of the site.

Is there any way to, for example, drop a symlink to the images directory inside the site directory, and then maybe have jekyll ignore it when the static files are generated?

Or is there another way to go about this that makes more sense?

4 Answers
  1. Make a project page for the images.
  2. Set up directory structure

    /home/git/svnpenn.github.io
    /home/git/img
    
  3. Run Jekyll

    # We cant add the symlink until after jekyll is done. We will remove the
    # site folder and wait for it to rebuild.
    rm -r _site
    jekyll --server &
    while [ ! -f _site/index.html ]
    do
      sleep 1
    done
    ln -s ../images _site/images
    

Note I was using this because I thought it would help publish time on GitHub pages. It does not. GitHub can take 1-10 minutes to publish depending on the server.

Related