{"id":23251565,"url":"https://github.com/dgarcia360/redirects-cli","last_synced_at":"2025-04-06T02:18:33.274Z","repository":{"id":41127998,"uuid":"508209418","full_name":"dgarcia360/redirects-cli","owner":"dgarcia360","description":"A CLI to create static redirections from a YAML file","archived":false,"fork":false,"pushed_at":"2023-09-05T05:37:22.000Z","size":18,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-12T08:20:52.460Z","etag":null,"topics":["cli","gh-pages","redirects","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgarcia360.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-28T08:03:35.000Z","updated_at":"2022-06-28T18:48:09.000Z","dependencies_parsed_at":"2025-02-15T20:01:18.286Z","dependency_job_id":null,"html_url":"https://github.com/dgarcia360/redirects-cli","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarcia360%2Fredirects-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarcia360%2Fredirects-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarcia360%2Fredirects-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarcia360%2Fredirects-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgarcia360","download_url":"https://codeload.github.com/dgarcia360/redirects-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423518,"owners_count":20936627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","gh-pages","redirects","yaml"],"created_at":"2024-12-19T09:18:55.421Z","updated_at":"2025-04-06T02:18:33.249Z","avatar_url":"https://github.com/dgarcia360.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redirects-cli\n\nA CLI to create static redirections from a YAML file.\n\n## Why?\n\nYou are relying on GitHub Pages to host your site. However, whenever you move a page from one folder to another, your users get the 404 page.\n\nWith `redirects-cli`, you can define 301 redirects for the pages you have moved in a YAML file. Then, you can generate static redirects for each page with one command.\n\nIn my case, I use this CLI tool in the project's CI pipelines before publishing the site to the `gh-pages` branch.\n\n## Getting started\n\n### Requirements\n\n* Python \u003e= 3.7\n* pip\n\n### Installation\n\n```\npip install redirects_cli\n```\n\n### Quickstart\n\n```\nredirects-cli --help\n```\n\n## Usage\n\n### Generate redirects from a static file\n\nTo generate static redirects from a YAML file:\n\n1. Define the redirects in a new file named `redirects.yaml`. This file must follow this syntax:\n\n    ```\n    # old_path: new_path\n    # Example\n\n    # internal link example\n    /original-path/page-a.html: /new-path/page-a.html\n\n    # external link example\n    /original-path/page-b.html: https://example.local\n    ```\n\n2. Run the command:\n\n    ```\n    redirects-cli fromfile --yaml-file redirects.yaml --output-dir html\n    ```\n\n    The CLI creates the static redirects you have defined in the `redirects.yaml` file within the folder `html`.\n    For this example, it creates the following folder structure:\n\n    ```\n    my-project/\n    ├─ html/\n    │  ├─ original-path/page-a.html\n    │  ├─ original-path/page-b.html\n    ├─ redirects.yaml\n    ```\n\n### Create a single redirect\n\nTo create a single redirect, you can run the command:\n\n```\nredirects-cli create --output-file index.html  --redirect-to https://davidgarcia.dev\n```\n\nThis command creates a 301 redirect to `https://davidgarcia.dev`in the file `index.html`.\n\n## Contributing\n\nContributions are welcome and appreciated!\nIf you want to enhance the CLI, please read [CONTRIBUTING.md](CONTRIBUTING.md) file first.\n\n## License\n\nCopyright (c) 2022-present David Garcia ([@dgarcia360](https://davidgarcia.dev)). Licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgarcia360%2Fredirects-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgarcia360%2Fredirects-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgarcia360%2Fredirects-cli/lists"}