Skip to content

Instantly share code, notes, and snippets.

@stevekrouse
Created October 24, 2017 01:33
Show Gist options
  • Select an option

  • Save stevekrouse/7d205a2d8b2719d0d96b5df391832c6c to your computer and use it in GitHub Desktop.

Select an option

Save stevekrouse/7d205a2d8b2719d0d96b5df391832c6c to your computer and use it in GitHub Desktop.

unbreakable-links: delete files without a panic attack

So you have a Github Pages website. It's pretty great, so you share links to your site. But then you delete pages and those links you shared break!

Unbreakable-links to the rescue.

By associating your content with its git commit hash, we make sure that your links never break.

How to install

Add the following script tag to every page in your website:

<script type="text/javascript" src="https://cdn.rawgit.com/stevekrouse/unbreakable-links/master/index.js" repoPath="stevekrouse/unbreakable-links"></script>
  • NOTE: don't forget to customize the repoPath attribute to what it is for you. *

Also, don't forget to add it to your 404.html page -- or create that page and add it if you haven't already.

We handle all the cases

| File | Commit Hash | Output | | ------------- |:-------------:| ------------------------------------------------------------------------------------------------ :| | currently exits | none in URL | "You are viewing the most recent version of this file." We also add the commit hash to the URL. | | currently exits | current hash | "You are viewing the most recent version of this file." | | currently exits | old hash | "There is a more recent version of this file." | | deleted | none in URL | "This file was deleted. Here is the most recent version." We also add the commit hash to the URL. | | deleted | current hash | "This file was deleted, but this is the most recent version that existed." | | deleted | old hash | "This file was deleted, but there is a more recent version than this one." | | never existed | N/A | "This file never existed" | | moved | N/A | not yet handled |

FAQ

Isn't this basically a server on the frontend?

Yes, yes it is. I may turn this into a backend service at some point.

Why did you make this?

I was tired of mapping out migration plans and wanted to be able to move around my thoughts with ease. You can read my full thought proccess here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment