robwierzbowski/generator-jekyllrb

Revisioning assets in jekyll template

agarrharr opened this issue · 2 comments

I've got a line in my default.html like this:

<footer class="col-md-12 site-footer" {% if site.data.blog.cover %}style="background-image: url({{site.data.blog.cover}})"{% endif %}>

I store the data in _data/blog.yml like this:

cover: /img/city.jpg

And it generates this html:

<footer class="col-md-12 site-footer" style="background-image: url(/img/city.jpg)">

The problem is that the actual image is revisioned to something like city.80c2.jpg

How can I make sure that I get the actual file name for the image?

Hi @Aharris88, have you tried eliminating the the "filerev" task in your Gruntfile.js by commenting out that line, something like the following:

grunt.registerTask('build', [
    'clean',
    // Jekyll cleans files from the target directory, so must run first
    'jekyll:dist',
    'concurrent:dist',
    'useminPrepare',
    'concat',
    'cssmin',
    'uglify',
    'imagemin',
    'svgmin',
    //'filerev',
    'usemin',
    'htmlmin'
    ]);

This won't fix your issue, but by eliminating the file number versioning all together, you might accomplish what you want. Hopefully someone with more knowledge on the "filerev" task can give you a better answer.

_data/blog.yml

these are not html files, so it is not covered by the default usemin block in Gruntfile.js.

usemin: {
options: {
assetsDirs: ['<%%= yeoman.dist %>', '<%%= yeoman.dist %>/<%= imgDir %>']
},
html: ['<%%= yeoman.dist %>/**/*.html'],
css: ['<%%= yeoman.dist %>/<%= cssDir %>/**/*.css']

https://github.com/yeoman/grunt-usemin#tasks

Pull requests to add comments to Gruntfile.js or README welcome.