26 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | title: Jekyll URL Shortener
2 | description: ✂️🔗 This is a template repository for making URL Shorteners with Jekyll and GitHub Pages. Create short URLs that can be easily shared, tweeted, or emailed to friends.
3 | logo: /assets/img/logo.png
4 | show_downloads: true
5 | google_analytics:
6 | theme: jekyll-theme-minimal
7 |
8 | permalink: /:slug/
9 |
10 | plugins:
11 | - jekyll-redirect-from
12 |
13 | github: [metadata]
14 |
15 | # Exclude from processing.
16 | # The following items will not be processed, by default. Create a custom list
17 | # to override the default setting.
18 | exclude:
19 | - README.md
20 | - LICENSE
21 | - CNAME
22 |
--------------------------------------------------------------------------------
/.github/workflows/autoapprove.yml:
--------------------------------------------------------------------------------
1 | name: Dependabot auto-approve
2 |
3 | # This workflow is triggered on pull requests opened by Dependabot
4 | on:
5 | pull_request:
6 | branches: [$default-branch] # master
7 |
8 | permissions:
9 | pull-requests: write
10 |
11 | jobs:
12 | dependabot:
13 | runs-on: ubuntu-latest
14 | if: github.actor == 'dependabot[bot]'
15 | steps:
16 | - name: Dependabot metadata
17 | id: metadata
18 | uses: dependabot/fetch-metadata@v2
19 | with:
20 | github-token: "${{ secrets.GITHUB_TOKEN }}"
21 | - name: Approve a PR
22 | run: gh pr review --approve "$PR_URL"
23 | env:
24 | PR_URL: ${{github.event.pull_request.html_url}}
25 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26 |
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | // For format details, see https://aka.ms/devcontainer.json.
2 | // For config options, see the README at:
3 | // https://github.com/devcontainers/templates/tree/main/src/jekyll
4 | {
5 | "name": "Jekyll",
6 | "image": "mcr.microsoft.com/devcontainers/jekyll",
7 |
8 | // List of ports inside the container available to be forwarded to the host
9 | "forwardPorts": [4000],
10 | "portsAttributes": {
11 | "4000": {
12 | "label": "Jekyll Live Server",
13 | "onAutoForward": "notify"
14 | }
15 | },
16 |
17 | // Commands to be run after the container is first created
18 | "postCreateCommand": "sudo apt-get update && sudo apt-get install -y imagemagick imagemagick-doc",
19 |
20 | "containerEnv": {
21 | "DEBIAN_FRONTEND": "noninteractive" // Prevents some apt-get warnings
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/_layouts/redirect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {% if site.google_analytics %}
4 |
5 |
6 |
12 | {% endif %}
13 |
14 | Redirecting…
15 |
16 |
17 |
18 |
19 |
Redirecting…
20 | Click here if you are not redirected.
21 |
22 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "jekyll-serve",
8 | "type": "shell",
9 | "command": "bundle exec jekyll serve --watch --force_polling --livereload --verbose",
10 | "group": {
11 | "kind": "build",
12 | "isDefault": true
13 | },
14 | "presentation": {
15 | "echo": true,
16 | "reveal": "always",
17 | "focus": false,
18 | "panel": "shared",
19 | "showReuseMessage": true,
20 | "clear": false
21 | },
22 | },
23 | {
24 | "label": "bundle-install",
25 | "type": "shell",
26 | "command": "bundle install",
27 | "group": {
28 | "kind": "build",
29 | "isDefault": false
30 | },
31 | },
32 | {
33 | "label": "bundle-update",
34 | "type": "shell",
35 | "command": "bundle update",
36 | "group": {
37 | "kind": "build",
38 | "isDefault": false
39 | },
40 | }
41 | ]
42 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Henrik Lau Eriksson
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 | # Hello! This is where you manage which Jekyll version is used to run.
3 | # When you want to use a different version, change it below, save the
4 | # file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
5 | #
6 | # bundle exec jekyll serve
7 | #
8 | # This will help ensure the proper Jekyll version is running.
9 | # Happy Jekylling!
10 | #gem "jekyll", "~> 4.3.2"
11 | # This is the default theme for new Jekyll sites. You may change this to anything you like.
12 | #gem "minima", "~> 2.5"
13 | # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
14 | # uncomment the line below. To upgrade, run `bundle update github-pages`.
15 | gem "github-pages", group: :jekyll_plugins
16 | # If you have any plugins, put them here!
17 | group :jekyll_plugins do
18 | gem "jekyll-redirect-from", "~> 0.16.0"
19 | end
20 |
21 | # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
22 | # and associated library.
23 | platforms :mingw, :x64_mingw, :mswin, :jruby do
24 | gem "tzinfo", ">= 1", "< 3"
25 | gem "tzinfo-data"
26 | end
27 |
28 | # Performance-booster for watching directories on Windows
29 | gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
30 |
31 | # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
32 | # do not have a Java counterpart.
33 | gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]
34 |
35 | gem "webrick", "~> 1.8", :platforms => [:mingw, :x64_mingw, :mswin]
36 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | activesupport (8.0.0)
5 | base64
6 | benchmark (>= 0.3)
7 | bigdecimal
8 | concurrent-ruby (~> 1.0, >= 1.3.1)
9 | connection_pool (>= 2.2.5)
10 | drb
11 | i18n (>= 1.6, < 2)
12 | logger (>= 1.4.2)
13 | minitest (>= 5.1)
14 | securerandom (>= 0.3)
15 | tzinfo (~> 2.0, >= 2.0.5)
16 | uri (>= 0.13.1)
17 | addressable (2.8.7)
18 | public_suffix (>= 2.0.2, < 7.0)
19 | base64 (0.2.0)
20 | benchmark (0.4.0)
21 | bigdecimal (3.1.8)
22 | coffee-script (2.4.1)
23 | coffee-script-source
24 | execjs
25 | coffee-script-source (1.12.2)
26 | colorator (1.1.0)
27 | commonmarker (0.23.10)
28 | concurrent-ruby (1.3.4)
29 | connection_pool (2.4.1)
30 | csv (3.3.0)
31 | dnsruby (1.72.2)
32 | simpleidn (~> 0.2.1)
33 | drb (2.2.1)
34 | em-websocket (0.5.3)
35 | eventmachine (>= 0.12.9)
36 | http_parser.rb (~> 0)
37 | ethon (0.16.0)
38 | ffi (>= 1.15.0)
39 | eventmachine (1.2.7)
40 | execjs (2.10.0)
41 | faraday (2.12.1)
42 | faraday-net_http (>= 2.0, < 3.5)
43 | json
44 | logger
45 | faraday-net_http (3.4.0)
46 | net-http (>= 0.5.0)
47 | ffi (1.17.0-x64-mingw-ucrt)
48 | ffi (1.17.0-x86_64-linux-gnu)
49 | forwardable-extended (2.6.0)
50 | gemoji (4.1.0)
51 | github-pages (232)
52 | github-pages-health-check (= 1.18.2)
53 | jekyll (= 3.10.0)
54 | jekyll-avatar (= 0.8.0)
55 | jekyll-coffeescript (= 1.2.2)
56 | jekyll-commonmark-ghpages (= 0.5.1)
57 | jekyll-default-layout (= 0.1.5)
58 | jekyll-feed (= 0.17.0)
59 | jekyll-gist (= 1.5.0)
60 | jekyll-github-metadata (= 2.16.1)
61 | jekyll-include-cache (= 0.2.1)
62 | jekyll-mentions (= 1.6.0)
63 | jekyll-optional-front-matter (= 0.3.2)
64 | jekyll-paginate (= 1.1.0)
65 | jekyll-readme-index (= 0.3.0)
66 | jekyll-redirect-from (= 0.16.0)
67 | jekyll-relative-links (= 0.6.1)
68 | jekyll-remote-theme (= 0.4.3)
69 | jekyll-sass-converter (= 1.5.2)
70 | jekyll-seo-tag (= 2.8.0)
71 | jekyll-sitemap (= 1.4.0)
72 | jekyll-swiss (= 1.0.0)
73 | jekyll-theme-architect (= 0.2.0)
74 | jekyll-theme-cayman (= 0.2.0)
75 | jekyll-theme-dinky (= 0.2.0)
76 | jekyll-theme-hacker (= 0.2.0)
77 | jekyll-theme-leap-day (= 0.2.0)
78 | jekyll-theme-merlot (= 0.2.0)
79 | jekyll-theme-midnight (= 0.2.0)
80 | jekyll-theme-minimal (= 0.2.0)
81 | jekyll-theme-modernist (= 0.2.0)
82 | jekyll-theme-primer (= 0.6.0)
83 | jekyll-theme-slate (= 0.2.0)
84 | jekyll-theme-tactile (= 0.2.0)
85 | jekyll-theme-time-machine (= 0.2.0)
86 | jekyll-titles-from-headings (= 0.5.3)
87 | jemoji (= 0.13.0)
88 | kramdown (= 2.4.0)
89 | kramdown-parser-gfm (= 1.1.0)
90 | liquid (= 4.0.4)
91 | mercenary (~> 0.3)
92 | minima (= 2.5.1)
93 | nokogiri (>= 1.16.2, < 2.0)
94 | rouge (= 3.30.0)
95 | terminal-table (~> 1.4)
96 | webrick (~> 1.8)
97 | github-pages-health-check (1.18.2)
98 | addressable (~> 2.3)
99 | dnsruby (~> 1.60)
100 | octokit (>= 4, < 8)
101 | public_suffix (>= 3.0, < 6.0)
102 | typhoeus (~> 1.3)
103 | html-pipeline (2.14.3)
104 | activesupport (>= 2)
105 | nokogiri (>= 1.4)
106 | http_parser.rb (0.8.0)
107 | i18n (1.14.6)
108 | concurrent-ruby (~> 1.0)
109 | jekyll (3.10.0)
110 | addressable (~> 2.4)
111 | colorator (~> 1.0)
112 | csv (~> 3.0)
113 | em-websocket (~> 0.5)
114 | i18n (>= 0.7, < 2)
115 | jekyll-sass-converter (~> 1.0)
116 | jekyll-watch (~> 2.0)
117 | kramdown (>= 1.17, < 3)
118 | liquid (~> 4.0)
119 | mercenary (~> 0.3.3)
120 | pathutil (~> 0.9)
121 | rouge (>= 1.7, < 4)
122 | safe_yaml (~> 1.0)
123 | webrick (>= 1.0)
124 | jekyll-avatar (0.8.0)
125 | jekyll (>= 3.0, < 5.0)
126 | jekyll-coffeescript (1.2.2)
127 | coffee-script (~> 2.2)
128 | coffee-script-source (~> 1.12)
129 | jekyll-commonmark (1.4.0)
130 | commonmarker (~> 0.22)
131 | jekyll-commonmark-ghpages (0.5.1)
132 | commonmarker (>= 0.23.7, < 1.1.0)
133 | jekyll (>= 3.9, < 4.0)
134 | jekyll-commonmark (~> 1.4.0)
135 | rouge (>= 2.0, < 5.0)
136 | jekyll-default-layout (0.1.5)
137 | jekyll (>= 3.0, < 5.0)
138 | jekyll-feed (0.17.0)
139 | jekyll (>= 3.7, < 5.0)
140 | jekyll-gist (1.5.0)
141 | octokit (~> 4.2)
142 | jekyll-github-metadata (2.16.1)
143 | jekyll (>= 3.4, < 5.0)
144 | octokit (>= 4, < 7, != 4.4.0)
145 | jekyll-include-cache (0.2.1)
146 | jekyll (>= 3.7, < 5.0)
147 | jekyll-mentions (1.6.0)
148 | html-pipeline (~> 2.3)
149 | jekyll (>= 3.7, < 5.0)
150 | jekyll-optional-front-matter (0.3.2)
151 | jekyll (>= 3.0, < 5.0)
152 | jekyll-paginate (1.1.0)
153 | jekyll-readme-index (0.3.0)
154 | jekyll (>= 3.0, < 5.0)
155 | jekyll-redirect-from (0.16.0)
156 | jekyll (>= 3.3, < 5.0)
157 | jekyll-relative-links (0.6.1)
158 | jekyll (>= 3.3, < 5.0)
159 | jekyll-remote-theme (0.4.3)
160 | addressable (~> 2.0)
161 | jekyll (>= 3.5, < 5.0)
162 | jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0)
163 | rubyzip (>= 1.3.0, < 3.0)
164 | jekyll-sass-converter (1.5.2)
165 | sass (~> 3.4)
166 | jekyll-seo-tag (2.8.0)
167 | jekyll (>= 3.8, < 5.0)
168 | jekyll-sitemap (1.4.0)
169 | jekyll (>= 3.7, < 5.0)
170 | jekyll-swiss (1.0.0)
171 | jekyll-theme-architect (0.2.0)
172 | jekyll (> 3.5, < 5.0)
173 | jekyll-seo-tag (~> 2.0)
174 | jekyll-theme-cayman (0.2.0)
175 | jekyll (> 3.5, < 5.0)
176 | jekyll-seo-tag (~> 2.0)
177 | jekyll-theme-dinky (0.2.0)
178 | jekyll (> 3.5, < 5.0)
179 | jekyll-seo-tag (~> 2.0)
180 | jekyll-theme-hacker (0.2.0)
181 | jekyll (> 3.5, < 5.0)
182 | jekyll-seo-tag (~> 2.0)
183 | jekyll-theme-leap-day (0.2.0)
184 | jekyll (> 3.5, < 5.0)
185 | jekyll-seo-tag (~> 2.0)
186 | jekyll-theme-merlot (0.2.0)
187 | jekyll (> 3.5, < 5.0)
188 | jekyll-seo-tag (~> 2.0)
189 | jekyll-theme-midnight (0.2.0)
190 | jekyll (> 3.5, < 5.0)
191 | jekyll-seo-tag (~> 2.0)
192 | jekyll-theme-minimal (0.2.0)
193 | jekyll (> 3.5, < 5.0)
194 | jekyll-seo-tag (~> 2.0)
195 | jekyll-theme-modernist (0.2.0)
196 | jekyll (> 3.5, < 5.0)
197 | jekyll-seo-tag (~> 2.0)
198 | jekyll-theme-primer (0.6.0)
199 | jekyll (> 3.5, < 5.0)
200 | jekyll-github-metadata (~> 2.9)
201 | jekyll-seo-tag (~> 2.0)
202 | jekyll-theme-slate (0.2.0)
203 | jekyll (> 3.5, < 5.0)
204 | jekyll-seo-tag (~> 2.0)
205 | jekyll-theme-tactile (0.2.0)
206 | jekyll (> 3.5, < 5.0)
207 | jekyll-seo-tag (~> 2.0)
208 | jekyll-theme-time-machine (0.2.0)
209 | jekyll (> 3.5, < 5.0)
210 | jekyll-seo-tag (~> 2.0)
211 | jekyll-titles-from-headings (0.5.3)
212 | jekyll (>= 3.3, < 5.0)
213 | jekyll-watch (2.2.1)
214 | listen (~> 3.0)
215 | jemoji (0.13.0)
216 | gemoji (>= 3, < 5)
217 | html-pipeline (~> 2.2)
218 | jekyll (>= 3.0, < 5.0)
219 | json (2.8.2)
220 | kramdown (2.4.0)
221 | rexml
222 | kramdown-parser-gfm (1.1.0)
223 | kramdown (~> 2.0)
224 | liquid (4.0.4)
225 | listen (3.9.0)
226 | rb-fsevent (~> 0.10, >= 0.10.3)
227 | rb-inotify (~> 0.9, >= 0.9.10)
228 | logger (1.6.1)
229 | mercenary (0.3.6)
230 | minima (2.5.1)
231 | jekyll (>= 3.5, < 5.0)
232 | jekyll-feed (~> 0.9)
233 | jekyll-seo-tag (~> 2.1)
234 | minitest (5.25.1)
235 | net-http (0.5.0)
236 | uri
237 | nokogiri (1.16.7-x64-mingw-ucrt)
238 | racc (~> 1.4)
239 | nokogiri (1.16.7-x86_64-linux)
240 | racc (~> 1.4)
241 | octokit (4.25.1)
242 | faraday (>= 1, < 3)
243 | sawyer (~> 0.9)
244 | pathutil (0.16.2)
245 | forwardable-extended (~> 2.6)
246 | public_suffix (5.1.1)
247 | racc (1.8.1)
248 | rb-fsevent (0.11.2)
249 | rb-inotify (0.11.1)
250 | ffi (~> 1.0)
251 | rexml (3.3.9)
252 | rouge (3.30.0)
253 | rubyzip (2.3.2)
254 | safe_yaml (1.0.5)
255 | sass (3.7.4)
256 | sass-listen (~> 4.0.0)
257 | sass-listen (4.0.0)
258 | rb-fsevent (~> 0.9, >= 0.9.4)
259 | rb-inotify (~> 0.9, >= 0.9.7)
260 | sawyer (0.9.2)
261 | addressable (>= 2.3.5)
262 | faraday (>= 0.17.3, < 3)
263 | securerandom (0.3.2)
264 | simpleidn (0.2.3)
265 | terminal-table (1.8.0)
266 | unicode-display_width (~> 1.1, >= 1.1.1)
267 | typhoeus (1.4.1)
268 | ethon (>= 0.9.0)
269 | tzinfo (2.0.6)
270 | concurrent-ruby (~> 1.0)
271 | tzinfo-data (1.2023.3)
272 | tzinfo (>= 1.0.0)
273 | unicode-display_width (1.8.0)
274 | uri (1.0.2)
275 | wdm (0.1.1)
276 | webrick (1.8.2)
277 |
278 | PLATFORMS
279 | x64-mingw-ucrt
280 | x86_64-linux
281 |
282 | DEPENDENCIES
283 | github-pages
284 | http_parser.rb (~> 0.6.0)
285 | jekyll-redirect-from (~> 0.16.0)
286 | tzinfo (>= 1, < 3)
287 | tzinfo-data
288 | wdm (~> 0.1.1)
289 | webrick (~> 1.8)
290 |
291 | BUNDLED WITH
292 | 2.4.13
293 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Jekyll URL Shortener
2 |
3 | > :scissors: :link: This is a template repository for making URL Shorteners with Jekyll and GitHub Pages. Create short URLs that can be easily shared, tweeted, or emailed to friends. Click **Use this template** to get started.
4 |
5 | View the URL Shortener in action:
6 |
7 | *
8 |
9 | Read a blog post about the URL Shortener:
10 |
11 | *
12 |
13 | Table of Contents:
14 |
15 | - [Getting Started](#getting-started)
16 | - [Domain](#domain)
17 | - [Repository](#repository)
18 | - [Configuration](#configuration)
19 | - [GitHub Pages](#github-pages)
20 | - [Links](#links)
21 | - [Built With](#built-with)
22 | - [Showcase](#showcase)
23 | - [Running Jekyll locally](#running-jekyll-locally)
24 | - [Customizations of the redirect template](#customizations-of-the-redirect-template)
25 |
26 | ## Getting Started
27 |
28 | Follow these steps to create your own URL Shortener:
29 |
30 | 1. Get a domain name
31 | 2. Configure the DNS for the domain
32 | 3. Click **Use this template** to create a repository
33 | 4. Edit the `_config.yml` file
34 | 5. Host on GitHub Pages
35 | 6. Create link pages
36 |
37 | ### Domain
38 |
39 | Get a *(preferably short)* domain name from your favorite [registrar](https://www.icann.org/en/accredited-registrars).
40 |
41 | You probably want to use an [apex domain](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages#using-an-apex-domain-for-your-github-pages-site) for your URL Shortener.
42 |
43 | Go to your DNS provider and [setup the apex domain](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#configuring-an-apex-domain).
44 |
45 | If you create DNS `A` records, point to the these GitHub IP addresses:
46 |
47 | ```
48 | 185.199.108.153
49 | 185.199.109.153
50 | 185.199.110.153
51 | 185.199.111.153
52 | ```
53 |
54 | ### Repository
55 |
56 | Creating a repository from this template:
57 |
58 | 1. Above the file list, click **Use this template** to [create a repository from this template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
59 | 2. Select **Create a new repository**.
60 |
61 | I prefer to use the *domain name* as the name for the repository when I host a site on GitHub Pages.
62 |
63 | Take the opportunity to edit the `Description` and `Website` of the repository. Also consider to add `topics` to categorize your repository.
64 |
65 | You probably want to rewrite the content of this `README.md` file.
66 |
67 | ### Development Container
68 |
69 | This repository has a [devcontainer](https://code.visualstudio.com/docs/devcontainers/create-dev-container) defined for use with Visual Studio Code.
70 | Upon opening the repository in Visual Studio Code, you will be prompted to reopen the repository in the devcontainer.
71 |
72 | This will install all the necessary dependencies to run Jekyll locally without having to install anything on your local machine.
73 |
74 | > **Note:** You need to have [Docker](https://www.docker.com/products/docker-desktop) installed on your local machine to use the devcontainer.
75 |
76 | You can also use [GitHub Codespaces](https://docs.github.com/codespaces), which is a cloud-based development environment for your repository. The devcontainer configuration will also make sure that Jekyll is installed and running in the Codespace.
77 |
78 | It also has vscode tasks defined for running Jekyll locally and serving the site.
79 |
80 | ### Configuration
81 |
82 | Edit the `_config.yml` file:
83 |
84 | ```yml
85 | title: Jekyll URL Shortener
86 | description: ✂️🔗 This is a template repository for making URL Shorteners with Jekyll and GitHub Pages. Create short URLs that can be easily shared, tweeted, or emailed to friends.
87 | logo: /assets/img/logo.png
88 | show_downloads: true
89 | google_analytics:
90 | theme: jekyll-theme-minimal
91 |
92 | permalink: /:slug/
93 |
94 | plugins:
95 | - jekyll-redirect-from
96 |
97 | github: [metadata]
98 | ```
99 |
100 | Change the `title` and `description` to something you like. Consider to use your own `logo` by replacing the `/assets/img/logo.png` image.
101 |
102 | The `show_downloads` flag indicates whether to provide downloads links for the code in the repository on the site.
103 |
104 | Set the `google_analytics` tracking code if you are interested in the website traffic.
105 |
106 | Read more about the `theme` at
107 |
108 | The global `permalink` for pages is set to `/:slug/`.
109 |
110 | > Permalinks are the output path for your pages, posts, or collections. They allow you to structure the directories of your source code different from the directories in your output.
111 |
112 | > Slugified title from the document’s filename (any character except numbers and letters is replaced as hyphen). May be overridden via the document’s `slug` front matter.
113 |
114 | Read more about permalinks at
115 |
116 | It is the `jekyll-redirect-from` plugin that does the redirecting from the *short link* to the *target page*.
117 |
118 | > Sometimes, you may want to redirect a site page to a totally different website.
119 |
120 | Read more about the plugin at
121 |
122 | You can find more useful `plugins` to add at
123 |
124 | ### GitHub Pages
125 |
126 | Go to the **GitHub Pages** settings for the repo: [/settings/pages](../../settings/pages)
127 |
128 | Configure the build and deployment to [publish from a branch](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch).
129 |
130 | Set the `Source` to:
131 |
132 | - `Deploy from a branch`
133 |
134 | Set the `Branch` to:
135 |
136 | - `main`
137 |
138 | and the folder to:
139 |
140 | - `/ (root)`
141 |
142 | Configure a [custom domain](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site) for the GitHub Pages site.
143 |
144 | Enter your domain name under `Custom domain` and click `Save`.
145 |
146 | This will create a `CNAME` file in the repo:
147 |
148 | ```txt
149 | example.com
150 | ```
151 |
152 | > Custom domains are stored in a `CNAME` file in the root of your repository. You can add or update your custom domain through your repository settings. You can also edit the file directly to update your custom domain.
153 |
154 | Make sure the `Enforce HTTPS` checkbox is ticked to [secure the GitHub Pages site](https://docs.github.com/en/pages/getting-started-with-github-pages/securing-your-github-pages-site-with-https).
155 |
156 | > HTTPS provides a layer of encryption that prevents others from snooping on or tampering with traffic to your site. When HTTPS is enforced, your site will only be served over HTTPS.
157 |
158 | Read more about GitHub Pages at
159 |
160 | ### Links
161 |
162 | Create a new short link by creating a [page](https://jekyllrb.com/docs/pages/).
163 |
164 | Create the file in the root of the repository.
165 |
166 | This repository has one example.
167 |
168 | [`repo.md`](repo.md):
169 |
170 | ```md
171 | ---
172 | title: Jekyll URL Shortener
173 | redirect_to: https://github.com/hlaueriksson/jekyll-url-shortener
174 | ---
175 | ```
176 |
177 | This results in:
178 |
179 | * "Short" link: https://hlaueriksson.github.io/jekyll-url-shortener/repo/
180 | * Target page: https://github.com/hlaueriksson/jekyll-url-shortener
181 | * *(Ironically the short link is 5 characters longer than the target page URL)*
182 |
183 | The `title` could be used to describe the target page. Consider to provide the *exact* title of the target page.
184 |
185 | The `redirect_to` is the URL to the target page. This is the only [front matter](https://jekyllrb.com/docs/front-matter/) that is mandatory to make the short link work.
186 |
187 | The file can have a `.md` (Markdown) or `.html` extension.
188 |
189 | By default, the file name will be the *slug* of the short link. This behavior is configured in `_config.yml`.
190 |
191 | If you want to use a different slug, set the `permalink` variable:
192 |
193 | ```md
194 | permalink: /something/
195 | ```
196 |
197 | Take the opportunity to get a real short slug by using *emojis*:
198 |
199 | ```md
200 | permalink: /😻/
201 | ```
202 |
203 | Find appropriate emojis to copy from
204 |
205 | ## Built With
206 |
207 | * Jekyll:
208 | * jekyll-theme-minimal:
209 | * jekyll-redirect-from:
210 | * GitHub Pages:
211 |
212 | ## Showcase
213 |
214 | | Repo | Site |
215 | | :--- | :--- |
216 | | https://github.com/hlaueriksson/hlaueriksson.me | https://hlaueriksson.me
217 |
218 | ## Running Jekyll locally
219 |
220 | Run:
221 |
222 | ```cmd
223 | bundle exec jekyll serve
224 | ```
225 |
226 | Browse:
227 |
228 | -
229 |
230 | Documentation:
231 |
232 | -
233 |
234 | ## Customizations of the redirect template
235 |
236 | The redirect template has been customized in this repository.
237 |
238 | [`_layouts/redirect.html`](_layouts/redirect.html):
239 |
240 | ```html
241 |
242 |
243 | {% if site.google_analytics %}
244 |
245 |
246 |
252 | {% endif %}
253 |
254 | Redirecting…
255 |
256 |
257 |
258 |
259 |
Redirecting…
260 | Click here if you are not redirected.
261 |
262 | ```
263 |
264 | The Google Analytics script is added at the top of the HTML.
265 |
266 | If the `google_analytics` tracking code is specified in `_config.yml`, then the script is rendered in the redirect template.
267 |
268 | Documentation:
269 |
270 | -
271 |
--------------------------------------------------------------------------------