{"id":27237637,"url":"https://github.com/sergeyzwezdin/hexo-generator-redirect","last_synced_at":"2025-04-10T18:25:32.481Z","repository":{"id":39564382,"uuid":"253023053","full_name":"sergeyzwezdin/hexo-generator-redirect","owner":"sergeyzwezdin","description":"Redirect pages generator for Hexo static site generator","archived":false,"fork":false,"pushed_at":"2023-08-25T04:02:36.000Z","size":120,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-09T05:12:10.727Z","etag":null,"topics":["hexo","hexo-plugin"],"latest_commit_sha":null,"homepage":"https://hexo.io/","language":"JavaScript","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/sergeyzwezdin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-04T14:49:20.000Z","updated_at":"2024-02-05T00:51:15.000Z","dependencies_parsed_at":"2022-09-02T05:23:43.623Z","dependency_job_id":null,"html_url":"https://github.com/sergeyzwezdin/hexo-generator-redirect","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyzwezdin%2Fhexo-generator-redirect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyzwezdin%2Fhexo-generator-redirect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyzwezdin%2Fhexo-generator-redirect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyzwezdin%2Fhexo-generator-redirect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergeyzwezdin","download_url":"https://codeload.github.com/sergeyzwezdin/hexo-generator-redirect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248270781,"owners_count":21075796,"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":["hexo","hexo-plugin"],"created_at":"2025-04-10T18:25:31.585Z","updated_at":"2025-04-10T18:25:32.469Z","avatar_url":"https://github.com/sergeyzwezdin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hexo-generator-redirect ![Publish on NPM](https://github.com/sergeyzwezdin/hexo-generator-redirect/workflows/Publish%20on%20NPM/badge.svg?branch=master) ![](https://img.shields.io/npm/v/hexo-generator-redirect)\n\n`hexo-generator-redirect` is a plugin for Hexo static site generator that generates additional redirect pages. It's useful if you migrate your website and changed addresses for some posts.\n\n* Migrate to new URLs **without the pain**.\n* **Easy to install** and use.\n* **Custom templates** for the redirect page.\n\n## How it works\n\nThe plugin generates additional HTML page for \"outdated\" URLs. These pages will contain information on where the page was moved to.\n\n## Requirements\n- Hexo: 4.x\n- Node 12+\n\n## Usage\n\n1. Install the plugin using npm:\n```bash\n$ npm install hexo-generator-redirect --save-dev\n```\n2. Add `redirect_from` key into frontmatter of the page:\n```yaml\nlayout: post\ntitle: Page\nredirect_from:\n- /old-url1\n- /old-url2\n```\n3. Create a layout template for the redirect page (for more details see below).\n4. Build the website 🤝.\n\n## Creating the template\n\nCreate `redirect.ejs` in the `layout` folder of your theme.\n\nYou can use the `post` variable in the template. To access the target page information, use `page.target.path`.\n\nHere is an example of the redirect page layout (`redirect.ejs`):\n\n```html\n\u003c% const newUrl = full_url_for(page.target.path) %\u003e\n\n\u003ch1\u003ePage address was changed\u003c/h1\u003e\n\u003cp\u003eThe new page address is \u003ca href=\"\u003c%= newUrl %\u003e\"\u003e\u003c%= newUrl %\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cscript type=\"text/javascript\"\u003e\n  setTimeout(function(){ document.location.href = '\u003c%= newUrl %\u003e'; }, 5000);\n\u003c/script\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergeyzwezdin%2Fhexo-generator-redirect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergeyzwezdin%2Fhexo-generator-redirect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergeyzwezdin%2Fhexo-generator-redirect/lists"}