Skip to content

Conversation

@AristurtleDev
Copy link
Contributor

@AristurtleDev AristurtleDev commented Jan 26, 2024

Description

This adds redirect functionality to the website through the following

  • A new collection called redirects has been created. The data for this collection is generated by the .config/collections/redirect.js module. In here, you can manually add redirects if needed for any future reasons.
    • This includes a section with a clear warning not to adjust the code. This section will generate redirections for all /article/**/*.md documents so that the old style links will redirect to the new style links and SEO isn't lost.
  • _includes/layouts/redirect.layout.njk
    • Simple redirect HTML page that uses the <meta> refresh method to redirect the user to the correct url.
    • Includes <meta name="robots" content="noindex""/> tag for robots/crawlers to inform them to not index the old page
    • Includes <link rel="canonical"> tag which informs search engines such as Google that the href being redirected to should be the canonical url for that page so that search engines will update over time.
  • content/redirects.md
    • Markdown file that contains only the YAML frontmatter and uses the 11ty pagination feature
    • Uses the permalink frontmatter to specify where the redirect page will be output to which is the old page url.

With these files, when the site is built, the redirects collection is autogenerated and handled by thecontents/redirect.md` file to generate the individual redirect pages for all urls that require redirects.

Note

Typically for redirects you would want the HTTP Response to be an HTTP 301: Permanent Redirect response. However, since this is a static website served from GitHub pages, we don't have control over the HTTP response that is sent, so this is the closest we can get to redirecting while also including tags to tell search engines to update over time.

Related Issues

This is a feature implementation for Issue #78

@AristurtleDev AristurtleDev marked this pull request as draft January 26, 2024 19:15
@AristurtleDev
Copy link
Contributor Author

Just realized, you would want this to redirect on every single article page from the old site that had the .html extension
Which would mean you'd need to manually add them to this file
One moment and I'll add the automation for that

@AristurtleDev
Copy link
Contributor Author

Updated to automate redirection of article documents from old style links to new style links.

@AristurtleDev AristurtleDev marked this pull request as ready for review January 26, 2024 19:44
@AristurtleDev
Copy link
Contributor Author

Closing this as it is no longer needed due to implementations from #91

@AristurtleDev AristurtleDev deleted the feature/redirect-links branch September 27, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant