Created
August 31, 2017 17:18
-
-
Save citrus/9b4db508e6b38efd98ed2e8d90b0d617 to your computer and use it in GitHub Desktop.
Jekyll permalink fix for pages without trailing slash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dir["**/*.html"].each do |file| | |
| next if file.include?("index.html") || file.start_with?("_") | |
| data = File.read(file) | |
| next if data.include?("permalink:") | |
| permalink = "/" + file.sub(".html", "/") | |
| puts "#{file} => #{permalink}" | |
| File.open(file, 'w') do |f| | |
| f.write(data.sub("---\n", "---\npermalink: #{permalink}\n")) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment