Skip to content
external-link

GitHub Action

GitHub Pages URL shortener

v1.1 Latest version

GitHub Pages URL shortener

external-link

GitHub Pages URL shortener

Use GitHub Pages as your URL shortener

Installation

Copy and paste the following snippet into your .yml file.

              

- name: GitHub Pages URL shortener

uses: zziger/[email protected]

Learn more about this action in zziger/url-shortener-action

Choose a version

URL shortener action

This action allows you to easily generate HTML pages needed for a simple URL shortener hosted on GitHub Pages. Can be useful for open-source projects to manage short URLs for e.g. documentation allowing contributors to create/edit them.

Inputs

path

Path to the uploaded website root

Default: .

json

Path to a config JSON file.

Default: links.json

template

Optional path to a custom template file for redirection pages.
GitHub Pages does not support returning 301/302, so in order to redirect this action uses <meta http-equiv="refresh"> tag.
Your custom template should contain the tag, every %URL% occurence in the template will be replaced with the actual URL.
For default template see template.html

Config JSON

Fields

links

Object with links. Key is a shortened url key, value is either string or object.
String value will make a redirection URL, object value allows to have grouped/nested URLs.

separators

Array with characters to separate group URL parts. See example below. Default is ["-"]

Example config

{
    "separators": ["-", "/"],
    "links": {
        "foo": "https://google.com",
        "bar": {
            "baz": "https://github.com"
        }
    }
}

This config will produce:

Example usage

uses: zziger/[email protected]
with:
    path: './public'
    json: './config.json'
    template: './mytemplate.html'