CodeForTucson / codefortucson-site

Current Code for Tucson website
http://www.codefortucson.org
GNU General Public License v2.0
3 stars 8 forks source link

Use a variable for the image directory base in <img> tags #50

Closed dmsnell closed 8 years ago

dmsnell commented 9 years ago

Previously we were referencing the full image directory after the basename in all of our image tags:

<img src="{{ site.basename }}/assets/images/my_image.jpg" />

Now I have declared a new variable in _config.yml to use to help prevent bugs from creeping in if that path changes and to standardize the location naming:

<img src="{{ site.basename }}/{{ site.img_dir }}/my_image.jpg" />

As you can see, it's not actually less writing to use this, however it is more resilient to sneaky bugs. I explored creating a variable within _config.yml that was composed of the site basename, but this does not appear possible.

There is a project on GitHub to allow using variables inside _config.yml but since we are constrained by GitHub's extensions, I do not believe this will help us.

Update I have confirmed that this is not available with the built-in Jekyll plugins on GitHub pages

meiqimichelle commented 8 years ago

I fixed some minor merge conflicts but other than that lgtm -- merging.

dmsnell commented 8 years ago

Since I happened to mention rebasing in the other PR, I'll bring it up here too because we have another use-case that's very legitimate, though I'll try to be short.

This PR isn't really about adding the FAQ section, but because we've manually imported those changes in, that new component gets conflated here and we end up having to review the two in unison. If we had instead rebased this branch, those changes would have most likely come through without any conflicts:

# Update local copy of master
# Oh look, someone has merged in changes
# since I started this branch....
git checkout master
git pull -p

# Update this branch via a rebase
git checkout add/img-dir-var
git rebase master

# Now those changes come in because we've changed the original branch parent
# and are left with only the changes relevant to this PR. Push it out! (Force to overwrite the history)
git push -f
dmsnell commented 8 years ago

Actually, @meiqimichelle I'm going to go ahead and rebase to show you......thought his might get sticky from the fix-changes commit. I just realized that you already merged...but here are the steps I would have taken.

My process: