{"id":22582913,"url":"https://github.com/n13org/jekyll-kw-sri","last_synced_at":"2026-06-22T19:31:25.659Z","repository":{"id":43453615,"uuid":"311260675","full_name":"n13org/jekyll-kw-sri","owner":"n13org","description":"A plugin for jekyll to calculate integrity hashes for CSS (even SCSS and SASS) and JS files","archived":false,"fork":false,"pushed_at":"2023-05-01T22:56:36.000Z","size":154,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-09T08:23:02.873Z","etag":null,"topics":["jekyll","jekyll-plugin","ruby","ruby-gem","sri"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/n13org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":"n-13-org","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-11-09T07:45:16.000Z","updated_at":"2021-01-07T09:28:27.000Z","dependencies_parsed_at":"2025-03-28T16:45:18.115Z","dependency_job_id":"d73babd5-f153-43a1-8520-3eb09c5b1751","html_url":"https://github.com/n13org/jekyll-kw-sri","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/n13org/jekyll-kw-sri","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n13org%2Fjekyll-kw-sri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n13org%2Fjekyll-kw-sri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n13org%2Fjekyll-kw-sri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n13org%2Fjekyll-kw-sri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n13org","download_url":"https://codeload.github.com/n13org/jekyll-kw-sri/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n13org%2Fjekyll-kw-sri/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34663523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jekyll","jekyll-plugin","ruby","ruby-gem","sri"],"created_at":"2024-12-08T06:12:54.387Z","updated_at":"2026-06-22T19:31:25.643Z","avatar_url":"https://github.com/n13org.png","language":"Ruby","funding_links":["https://opencollective.com/n-13-org"],"categories":[],"sub_categories":[],"readme":"# jekyll-kw-sri\n\n![CI](https://github.com/n13org/jekyll-kw-sri/workflows/CI/badge.svg)\n![Coverage](https://github.com/n13org/jekyll-kw-sri/workflows/Coverage/badge.svg)\n![RuboCop](https://github.com/n13org/jekyll-kw-sri/workflows/RuboCop/badge.svg)\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/a82f10c3cd9fea769a0b/maintainability)](https://codeclimate.com/github/n13org/jekyll-kw-sri/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/a82f10c3cd9fea769a0b/test_coverage)](https://codeclimate.com/github/n13org/jekyll-kw-sri/test_coverage)\n\n[![Gem Version](https://badge.fury.io/rb/jekyll-kw-sri.svg)](https://badge.fury.io/rb/jekyll-kw-sri)\n\nA plugin for [jekyll][Jekyll Website] to calculate [Subresource Integrity][Wikipedia SRI] (SRI) hashes for CSS (even SCSS and SASS) and JS files during build time.\n\n\u003e **Subresource Integrity** (SRI) is a security feature that enables browsers to verify that resources they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched resource must match.\n\nfrom [Mozilla docs][Mozilla Subresource Integrity]\n\n## Installation\n\nAdd this section to your application's `Gemfile` inside the `jekyll_plugins` and execute `bundle install`\n\n```ruby\ngroup :jekyll_plugins do\n  gem 'jekyll-kw-sri'\nend\n```\n\nOr install the dependency with `bundle` itself, you can use the option `--skip-install`, when `bundle install` will be called later\n\n```sh\nbundle add jekyll-kw-sri --group jekyll_plugins \n```\n\nThen add the following to your site's `_config.yml` to activate the plugin, see also the [Configuration](#%EF%B8%8F-configuration) section to change the default configuration. \n\n```yaml\nplugins:\n  - jekyll-kw-sri\n```\n\n\u003e The Plug-In is tested with jekyll 3.8, 3.9, 4.0 and 4.1!\n\n## 🔥 Usage \n\n### Usage for version `\u003e= v0.1.0`\n\nUse the [Jekyll Includes] `kw-integrity-css.html` for css, scss and sass; and the `kw-integrity-js.html` for js. \n\n\u003e For static, non-rendered `css` files the hash values have to me calculated and stored in a file. See `Action Items / Shell commands` section about SRI! All the hash-files should be stored in `./_includes/integrity` so they can easy used.\n\nThe markdown syntax shows the include file with one paramter \"the filename\". \n\n```markdown\n{% include kw-integrity-css.html file='style.scss' %}\n```\n\nThe rendered html will use the default path, the css file and the calculated hash.\n\n```html\n\u003clink rel=\"stylesheet\" href=\"/assets/css/style.css\" integrity=\"sha384-cl6CK1yzEvoM3Sw3dL8YAm/P2VpQiD+mAFVkkb6Bh+23PP1ow2gXXGw4WnQlzO0B\" crossorigin=\"anonymous\"\u003e\n```\n\nThe markdown syntax shows the include file with all paramters. All parameter can be omit. The **default values** are file = \"main.scss\", path = \"assets/css/\" and hash = \"sha384\".\n\n```markdown\n{% include kw-integrity-css.html file='style.scss' path='my/folder/to/css/' hash='sha512' %}\n```\n\n### Usage for version `\u003c v0.1.0`\n\nUse the [custom tag][Jekyll Liquid] sri_scss_hash {% raw %}`{% sri_scss_hash style.css %}`{% endraw %}. \n\n\u003e This approach was inspired by [vcsjones.dev Blog] and [vcsjones.dev GitHub].\n\nThe `html` inside the post or page markdown file, shows a usage of a `scss` file which will be compiled to a `css`. The hash of the integrity will be generated during the build time. \n\n```html\n\u003clink rel=\"stylesheet\" href=\"{{ '/assets/css/kargware.css' | relative_url }}\" integrity=\"{% sri_scss_hash /assets/css/kargware.scss %}\" crossorigin=\"anonymous\"\u003e\n```\n\nThe result of the html inside the markdown is the `href` and the `integrity`.\n\n```html\n\u003clink rel=\"stylesheet\" href=\"/assets/css/kargware.css\" integrity=\"sha384-cl6CK1yzEvoM3Sw3dL8YAm/P2VpQiD+mAFVkkb6Bh+23PP1ow2gXXGw4WnQlzO0B\" crossorigin=\"anonymous\"\u003e\n```\n\n## Changelog\n\n* 0.1.0 Add html include files to use them with  `{% include kw-integrity-css.html %}` or `{% include kw-integrity-js.html %}`\n* 0.0.x Add the custom tag `{% sri_scss_hash %}`\n\n## ⚙️ Configuration\n\nAdd `kw-sri` section to `_config.yml` configure the plugin globally. If you want to use defauls you can ommit the config-section.\n\n```yaml\nkw-sri:\n  createTmpfile: false\n  hash_type: 'sha384'\n  write_source_mapping_url: true\n```\n\n Configuration values\n\n| Key                      | Description                                       | Values (**default**)       |\n|--------------------------|---------------------------------------------------|----------------------------|\n| createTmpfile            | Debug-Only, save the rendered sass or scss as css | **false**, true            |\n| hash_type                | Which kind of integrity hash                      | sha256, **sha384**, sha512 |\n| write_source_mapping_url | Add the map-file like to the css                  | false, **true**            |              \n\n## 🚀 Action Items / Shell commands\n\nRun linting and tests\n\n```sh\nbundle exec rubocop\nbundle exec rake test\n```\n\nBuild gem package\n\n```sh\nbundle exec rake build\n```\n\nPublish gem package\n\n```sh\nbundle exec rake release\n```\n\nCalc a SRI Integrity hash of `./style.css` in format `sha256`\n\n```shell\nopenssl dgst -sha256 -binary ./style.css | openssl base64 -A\n```\n\nCalc different **SRI integrity** hash-files from `css-files` (same is valid for `js-files`) in format `sha256`, `sha384` and `sha512` inside a **Makefile**\n\n```plain\ncalc-integrity-files:\n\tfor strength in 256 384 512 ; do \\\n\t\tcat ./assets/css/style.min.css | openssl dgst -sha$$strength -binary | openssl base64 -A \u003e ./_includes/integrity/style.min.css.sha$$strength ; \\\n\t\tcat ./assets/css/main.css | openssl dgst -sha$$strength -binary | openssl base64 -A \u003e ./_includes/integrity/main.css.sha$$strength ; \\\n\t\tcat ./assets/js/script.js | openssl dgst -sha$$strength -binary | openssl base64 -A \u003e ./_includes/integrity/script.js.sha$$strength ; \\\n\tdone\n```\n\n## 📝 Notes / Hints\n\n### Appraisal - Gemfile Generator\n\n[GitHub](https://github.com/thoughtbot/appraisal)\n\n1. Create a `Appraisals` file\n2. Generate `Gemfiles`\n\n```sh\nbundle exec appraisal generate\n```\n\n### Site context is empty\n\nInside the `render(context)` function of a `Liquid::Tag` there is a context object. With that context you can get the `site` object, anyhow when you want to cretae your temporry **site** and **context** you need a workaround.\n\nNormal way to get the site object from the render function of a custom tag\n\n```ruby\nsite = context.registers[:site]\n```\n\nCreate a temporary site and context of a **jekyll** environment\n\n```ruby\nsite = Jekyll::Site.new(Jekyll::Configuration::DEFAULTS)\ncontext = Liquid::Context.new({}, {}, { site: site })\n```         \n\n### Base class for custom tag\nUse `Jekyll::Tags::IncludeRelativeTag` instead of `Liquid::Tag` as base class of the custom jekyll tag `SriScssHashTag` will help to read the content of the scss or sass files.\n\n### Find Scss converter\n\nSometimes, especially during testing, the site object is not perfectly setup. So the function `find_converter_instance` will throw an error. \n\n**Default** implementation to find the converter.\n\n```ruby\nconverter = site.find_converter_instance(Jekyll::Converters::Scss)\n```\n\n**Workaround** implementation to find the converter.\n\n```ruby\nconverter = if defined? site.find_converter_instance\n              site.find_converter_instance(Jekyll::Converters::Scss)\n            else\n              site.getConverterImpl(::Jekyll::Converters::Scss)\n            end\n```\n\n### Setup Steps\n\n```sh\nbundle init\nbundle add rake\nbundle add simplecov\nbundle add minitest\nbundle add minitest-reporters\nbundle add minitest-profile\nbundle add rspec-mocks\nbundle add rdiscount\nbundle add redcarpet\nbundle add shoulda\n```\n\n## 👋 Big Thanks to my inspiration sources\n\n* `SRI with Jekyll` [vcsjones.dev Blog] and [vcsjones.dev GitHub]\n* [GitHub Project jekyll/jekyll]\n* [GitHub Project Shopify/liquid]\n* [Medium wrap-your-assets-in-a-gem]\n* `Use jekyll filter scssify` [andreaverlicchi blog scssify]\n* [Blog How to create customizable Liquid tags in Jekyll]\n* [Ruby Module Digest]\n\n[Jekyll Website]: https://jekyllrb.com/\n[Jekyll Liquid]: https://jekyllrb.com/docs/liquid/\n[Jekyll Includes]: https://jekyllrb.com/docs/includes/\n[Wikipedia SRI]: https://en.wikipedia.org/wiki/Subresource_Integrity\n[Mozilla Subresource Integrity]: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity\n[vcsjones.dev Blog]: https://vcsjones.dev/2016/11/02/sri-with-jekyll/\n[vcsjones.dev GitHub]: https://github.com/vcsjones/vcsjones.dev/tree/main\n[GitHub Project jekyll/jekyll]: https://github.com/jekyll/jekyll\n[GitHub Project Shopify/liquid]: https://github.com/Shopify/liquid\n[andreaverlicchi blog scssify]: https://www.andreaverlicchi.eu/critical-css-jekyll-sass-github-pages/\n[Ruby Module Digest]: https://ruby-doc.com/stdlib/libdoc/digest/rdoc/Digest.html\n[Blog How to create customizable Liquid tags in Jekyll]: https://blog.sverrirs.com/2016/04/custom-jekyll-tags.html\n[Medium wrap-your-assets-in-a-gem]: https://medium.com/@paulfarino/wrap-your-assets-in-a-gem-3ad7ecf5b075\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn13org%2Fjekyll-kw-sri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn13org%2Fjekyll-kw-sri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn13org%2Fjekyll-kw-sri/lists"}