-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add trailing slash before anchors #3
Conversation
With Hugo and GitHub Pages there is a redirect for all folders to have a trailing slash that breaks anchors. Modify the links that contain anchors to include this slash and avoid the redirect. Signed-off-by: Matthias Aßhauer <[email protected]>
xlink = html.scan(/href="(https:\/\/git-scm\.com\/.*?[^\/])\#(.*?)"/) | ||
xlink&.each do |link| | ||
begin | ||
html.gsub!("href=\"#{link.first}\##{link[1]}\"", "href=\"#{link.first}/\##{link[1]}\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe these should be converted to relative links in the process, instead of making them absolute again.
Also these are technically broken with this change since the absolute links still point to the rails site.
I wonder if it would work if we added "slash-less" |
Ah, probably not because the A hack that seems to work over here is to add this step to the GitHub workflow: find public -name \*.html -exec grep -Zl '<meta http-equiv="refresh"' {} \; |
xargs -0r sed -i '/<\/html>/i\
<script>\
window.location.replace(`${document.title}${window.location.hash}`)\
</script>' What do you think @rimrul? |
Oh, I think I found something: https://gohugo.io/getting-started/configuration/#uglyurls. We may want to do that, and then also ensure that What do you think @rimrul? |
That should work. I came across that setting, but read that as having to use the |
I believe that this is working on https://dscho.github.io/git-scm.com/ now. |
# The 1st commit message will be skipped: # ci: update the books via a GitHub workflow # # With this commit, the SHAs corresponding to the various repositories # containing the ProGit Book and its translations are stored in a # sparse-checkout'able directory. # # This information is then used by a scheduled workflow to determine what # needs to be updated (if anything) and then performing that task. # # Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #2 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #3 will be skipped: # fixup! ci: update the books via a GitHub workflow # This is the commit message #4: # amend! ci: update the books via a GitHub workflow ci: update the books via a GitHub workflow With this commit, the SHAs corresponding to the various repositories containing the ProGit Book and its translations are stored in a sparse-checkout'able directory. This information is then used by a scheduled workflow to determine what needs to be updated (if anything) and then performing that task. When GitHub workflows push new changes, they cannot trigger other GitHub workflows (to avoid infinite loops). Therefore, this new GitHub workflow not only synchronizes the books, but also builds the site and deploys it. Note: The code to build the site and to deploy it is provided in a custom Action, to make it reusable. It will come in handy over the next commits, where other GitHub workflows are added that likewise need to synchronize changes that desire a site rebuild & deployment. Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #5 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #6 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #7 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #8 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #9 will be skipped: # fixup! ci: update the books via a GitHub workflow
# The 1st commit message will be skipped: # ci: update the books via a GitHub workflow # # With this commit, the SHAs corresponding to the various repositories # containing the ProGit Book and its translations are stored in a # sparse-checkout'able directory. # # This information is then used by a scheduled workflow to determine what # needs to be updated (if anything) and then performing that task. # # Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #2 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #3 will be skipped: # fixup! ci: update the books via a GitHub workflow # This is the commit message #4: # amend! ci: update the books via a GitHub workflow ci: update the books via a GitHub workflow With this commit, the SHAs corresponding to the various repositories containing the ProGit Book and its translations are stored in a sparse-checkout'able directory. This information is then used by a scheduled workflow to determine what needs to be updated (if anything) and then performing that task. When GitHub workflows push new changes, they cannot trigger other GitHub workflows (to avoid infinite loops). Therefore, this new GitHub workflow not only synchronizes the books, but also builds the site and deploys it. Note: The code to build the site and to deploy it is provided in a custom Action, to make it reusable. It will come in handy over the next commits, where other GitHub workflows are added that likewise need to synchronize changes that desire a site rebuild & deployment. Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #5 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #6 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #7 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #8 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #9 will be skipped: # fixup! ci: update the books via a GitHub workflow
# The 1st commit message will be skipped: # ci: update the books via a GitHub workflow # # With this commit, the SHAs corresponding to the various repositories # containing the ProGit Book and its translations are stored in a # sparse-checkout'able directory. # # This information is then used by a scheduled workflow to determine what # needs to be updated (if anything) and then performing that task. # # Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #2 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #3 will be skipped: # fixup! ci: update the books via a GitHub workflow # This is the commit message #4: # amend! ci: update the books via a GitHub workflow ci: update the books via a GitHub workflow With this commit, the SHAs corresponding to the various repositories containing the ProGit Book and its translations are stored in a sparse-checkout'able directory. This information is then used by a scheduled workflow to determine what needs to be updated (if anything) and then performing that task. When GitHub workflows push new changes, they cannot trigger other GitHub workflows (to avoid infinite loops). Therefore, this new GitHub workflow not only synchronizes the books, but also builds the site and deploys it. Note: The code to build the site and to deploy it is provided in a custom Action, to make it reusable. It will come in handy over the next commits, where other GitHub workflows are added that likewise need to synchronize changes that desire a site rebuild & deployment. Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #5 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #6 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #7 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #8 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #9 will be skipped: # fixup! ci: update the books via a GitHub workflow
# The 1st commit message will be skipped: # ci: update the books via a GitHub workflow # # With this commit, the SHAs corresponding to the various repositories # containing the ProGit Book and its translations are stored in a # sparse-checkout'able directory. # # This information is then used by a scheduled workflow to determine what # needs to be updated (if anything) and then performing that task. # # Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #2 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #3 will be skipped: # fixup! ci: update the books via a GitHub workflow # This is the commit message #4: # amend! ci: update the books via a GitHub workflow ci: update the books via a GitHub workflow With this commit, the SHAs corresponding to the various repositories containing the ProGit Book and its translations are stored in a sparse-checkout'able directory. This information is then used by a scheduled workflow to determine what needs to be updated (if anything) and then performing that task. When GitHub workflows push new changes, they cannot trigger other GitHub workflows (to avoid infinite loops). Therefore, this new GitHub workflow not only synchronizes the books, but also builds the site and deploys it. Note: The code to build the site and to deploy it is provided in a custom Action, to make it reusable. It will come in handy over the next commits, where other GitHub workflows are added that likewise need to synchronize changes that desire a site rebuild & deployment. Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #5 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #6 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #7 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #8 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #9 will be skipped: # fixup! ci: update the books via a GitHub workflow
# The 1st commit message will be skipped: # ci: update the books via a GitHub workflow # # With this commit, the SHAs corresponding to the various repositories # containing the ProGit Book and its translations are stored in a # sparse-checkout'able directory. # # This information is then used by a scheduled workflow to determine what # needs to be updated (if anything) and then performing that task. # # Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #2 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #3 will be skipped: # fixup! ci: update the books via a GitHub workflow # This is the commit message #4: # amend! ci: update the books via a GitHub workflow ci: update the books via a GitHub workflow With this commit, the SHAs corresponding to the various repositories containing the ProGit Book and its translations are stored in a sparse-checkout'able directory. This information is then used by a scheduled workflow to determine what needs to be updated (if anything) and then performing that task. When GitHub workflows push new changes, they cannot trigger other GitHub workflows (to avoid infinite loops). Therefore, this new GitHub workflow not only synchronizes the books, but also builds the site and deploys it. Note: The code to build the site and to deploy it is provided in a custom Action, to make it reusable. It will come in handy over the next commits, where other GitHub workflows are added that likewise need to synchronize changes that desire a site rebuild & deployment. Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #5 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #6 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #7 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #8 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #9 will be skipped: # fixup! ci: update the books via a GitHub workflow
# The 1st commit message will be skipped: # ci: update the books via a GitHub workflow # # With this commit, the SHAs corresponding to the various repositories # containing the ProGit Book and its translations are stored in a # sparse-checkout'able directory. # # This information is then used by a scheduled workflow to determine what # needs to be updated (if anything) and then performing that task. # # Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #2 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #3 will be skipped: # fixup! ci: update the books via a GitHub workflow # This is the commit message #4: # amend! ci: update the books via a GitHub workflow ci: update the books via a GitHub workflow With this commit, the SHAs corresponding to the various repositories containing the ProGit Book and its translations are stored in a sparse-checkout'able directory. This information is then used by a scheduled workflow to determine what needs to be updated (if anything) and then performing that task. When GitHub workflows push new changes, they cannot trigger other GitHub workflows (to avoid infinite loops). Therefore, this new GitHub workflow not only synchronizes the books, but also builds the site and deploys it. Note: The code to build the site and to deploy it is provided in a custom Action, to make it reusable. It will come in handy over the next commits, where other GitHub workflows are added that likewise need to synchronize changes that desire a site rebuild & deployment. Signed-off-by: Johannes Schindelin <[email protected]> # The commit message #5 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #6 will be skipped: # fixup! fixup! ci: update the books via a GitHub workflow # The commit message #7 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #8 will be skipped: # fixup! ci: update the books via a GitHub workflow # The commit message #9 will be skipped: # fixup! ci: update the books via a GitHub workflow
Changes
Modify the links that contain anchors to include a slash before the anchor to avoid the redirect.
Context
With Hugo and GitHub Pages there is a redirect for all folders to have a trailing slash that breaks anchors.