You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+24-21
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,12 @@ _Counterpart to the [redirects-website repo](../../../redirects-website)._
12
12
13
13
1. Add/change/remove redirect entries in one or more [`.yaml` files in the top folder](../../blob/main/redirects.yaml).
14
14
Note: the `from` field is **case-insensitive**.
15
-
2. Commit the changes to the `main` branch, either directly or with a pull request (recommended so the automatic process can catch errors before the changes go live).
16
-
3. Changes should take effect automatically within a minute or so.
15
+
1. Commit the changes to the `main` branch, either directly or with a pull request (recommended so the automatic process can catch errors before the changes go live).
16
+
1. Changes should take effect automatically within a minute or so.
17
17
Verify that no errors occurred in the automatic process here: [](../../actions/workflows/deploy.yaml)
18
+
1. Verify that none of your redirect links are reported broken in the automatic process here: [](../../actions/workflows/check.yaml).
19
+
Note that this is only a **rough check**.
20
+
There _may be false positives or true negatives_, as it simply checks the [status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) of the link, which the third-party may choose inappropriately.
18
21
19
22
You can do this [directly on github.com](../../edit/main/redirects.yaml) (tip: press <kbd>.</kbd> right now), or locally with git.
20
23
@@ -96,19 +99,19 @@ After the one-time setup, **all you have to do is edit the `.yaml` files, and ev
96
99
Adding/removing/changing a link goes like this:
97
100
98
101
1. You change one or more of the `.yaml` files in the _redirects repo_.
99
-
2.`deploy.yaml` tells [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) that any time someone commits a change to the repo, it should automatically run the `encode.js` script.
100
-
3. The `encode.js` script combines all of your `.yaml` files into one, and encodes it[^1].
101
-
4.`deploy.yaml` then tells GitHub to take the result of the `encode.js` script and commit it to the `redirect.js` script in the _website repo_.
102
-
5. In the _website repo_, GitHub Pages detects a change in the `redirect.js` script, and updates the website.
102
+
1.`deploy.yaml` tells [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) that any time someone commits a change to the repo, it should automatically run the `encode.js` script.
103
+
1. The `encode.js` script combines all of your `.yaml` files into one, and encodes it[^1].
104
+
1.`deploy.yaml` then tells GitHub to take the result of the `encode.js` script and commit it to the `redirect.js` script in the _website repo_.
105
+
1. In the _website repo_, GitHub Pages detects a change in the `redirect.js` script, and updates the website.
103
106
104
107
Then, a user visiting a link goes like this:
105
108
106
109
1. They navigate to a link on the website, e.g. `/chatroom`.
107
-
2.`chatroom.html` isn't a file in the _website repo_, and thus isn't a page on the website, so GitHub loads [`404.html`](https://en.wikipedia.org/wiki/HTTP_404) for the user instead (but preserves the `/chatroom` url).
110
+
1.`chatroom.html` isn't a file in the _website repo_, and thus isn't a page on the website, so GitHub loads [`404.html`](https://en.wikipedia.org/wiki/HTTP_404) for the user instead (but preserves the `/chatroom` url).
108
111
This file immediately runs some scripts:
109
-
3. The analytics code snippet sends[^2] stats like url, IP, date, time, location, etc. off to Google Analytics or whoever.
110
-
4. The `redirect.js` script decodes the redirect lists previously encoded from the _redirects repo_, finds the long url corresponding to "chatroom" (**case-insensitive**), and navigates there instead.
111
-
5. They arrive at the intended destination, e.g. `zoom.us/j/12345abcdef`, with virtually no perceptible delay.
112
+
1. The analytics code snippet sends[^2] stats like url, IP, date, time, location, etc. off to Google Analytics or whoever.
113
+
1. The `redirect.js` script decodes the redirect lists previously encoded from the _redirects repo_, finds the long url corresponding to "chatroom" (**case-insensitive**), and navigates there instead.
114
+
1. They arrive at the intended destination, e.g. `zoom.us/j/12345abcdef`, with virtually no perceptible delay.
112
115
113
116
## Setup
114
117
@@ -117,10 +120,10 @@ Then, a user visiting a link goes like this:
117
120
1.[Use the _redirects repo_ (this repo) as a template](https://github.com/CU-DBMI/redirects/generate).
118
121
**Do not fork**, because you cannot make forks private.
119
122
_Name it `redirects` and make it private_.
120
-
2.[Use the _website repo_ as a template](https://github.com/CU-DBMI/redirects-website/generate).
123
+
1.[Use the _website repo_ as a template](https://github.com/CU-DBMI/redirects-website/generate).
121
124
_Name it `redirects-website` and make it public_.
122
-
3.[Enable GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) on your copied _website repo_ with the default settings.
123
-
4. After a minute or so, GitHub should tell you that your site is now being hosted at `your-org.github.io/redirects-website`.
125
+
1.[Enable GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) on your copied _website repo_ with the default settings.
126
+
1. After a minute or so, GitHub should tell you that your site is now being hosted at `your-org.github.io/redirects-website`.
124
127
125
128
If you ever need to pull in updates from these templates, [see the instructions here](https://stackoverflow.com/questions/56577184/github-pull-changes-from-a-template-repository).
126
129
@@ -129,8 +132,8 @@ If you ever need to pull in updates from these templates, [see the instructions
129
132
To allow your _redirects repo_ to automatically write to your _website repo_, you need to "connect" them with a deploy key:
130
133
131
134
1.[Generate an SSH key pair](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key).
132
-
2. In your _redirects repo_, [create a new repository actions secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) named `DEPLOY_KEY`, and paste the private SSH key.
133
-
3. In your _website repo_, [create a new deploy key](https://docs.github.com/en/developers/overview/managing-deploy-keys#setup-2) with write/push access named `DEPLOY_KEY`, and paste the public SSH key.
135
+
1. In your _redirects repo_, [create a new repository actions secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) named `DEPLOY_KEY`, and paste the private SSH key.
136
+
1. In your _website repo_, [create a new deploy key](https://docs.github.com/en/developers/overview/managing-deploy-keys#setup-2) with write/push access named `DEPLOY_KEY`, and paste the public SSH key.
134
137
135
138
### Set up analytics
136
139
@@ -155,17 +158,17 @@ e.g. `your-domain.com/some-link`
155
158
In summary:
156
159
157
160
1. Purchase a domain name from a reputable service.
158
-
2. Point your domain name provider to GitHub Pages using an `A` record.
161
+
1. Point your domain name provider to GitHub Pages using an `A` record.
159
162
This is slightly different for each company; they should have their own instructions on how to do it.
160
-
3. Set the custom domain field in the "Pages" settings of your _website repo_ (automatically creates a `CNAME` file in the repo).
161
-
4. After a minute or so, GitHub should tell you that your site is now being hosted at `your-domain.com`.
163
+
1. Set the custom domain field in the "Pages" settings of your _website repo_ (automatically creates a `CNAME` file in the repo).
164
+
1. After a minute or so, GitHub should tell you that your site is now being hosted at `your-domain.com`.
162
165
163
166
#### GitHub user/org site
164
167
165
168
e.g. `your-org.github.io/some-link`
166
169
167
170
1. Name your _website repo_`your-org.github.io` to match your GitHub user/organization name.
168
-
2. In your _redirects repo_, change `redirects-website` in `deploy.yaml` to the same name.
171
+
1. In your _redirects repo_, change `redirects-website` in `deploy.yaml` to the same name.
If you already have a website being hosted with GitHub Pages that you want to incorporate this approach into:
189
192
190
193
1. Skip templating the _website repo_.
191
-
2. Instead, copy its [`redirect.js` script](https://github.com/CU-DBMI/redirects-website/blob/main/redirect.js) into the **top folder** of your existing website repo, and modify `baseurl` in it as appropriate.
192
-
3. Include the script in your 404 page in the [same way it is done here](https://github.com/CU-DBMI/redirects-website/blob/main/404.html).
194
+
1. Instead, copy its [`redirect.js` script](https://github.com/CU-DBMI/redirects-website/blob/main/redirect.js) into the **top folder** of your existing website repo, and modify `baseurl` in it as appropriate.
195
+
1. Include the script in your 404 page in the [same way it is done here](https://github.com/CU-DBMI/redirects-website/blob/main/404.html).
193
196
If an existing page and a redirect have same name/path, the redirect won't happen since the user won't get a [`404`](https://en.wikipedia.org/wiki/HTTP_404).
194
197
195
198
If your existing website is built and hosted in a different way, this approach would require modification[^3] and might not be appropriate for you.
0 commit comments