Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect URLS in form /<n> to /tips/<n> #56

Open
delphidabbler opened this issue May 23, 2022 · 4 comments
Open

Redirect URLS in form /<n> to /tips/<n> #56

delphidabbler opened this issue May 23, 2022 · 4 comments
Assignees
Labels
considering Considering or investigating the issue enhancement New feature or request

Comments

@delphidabbler
Copy link
Owner

Using the URL tips.delphidabbler.com/<n> instead of tips.delphidabbler.com/tips/<n> is much friendlier. Is there any way to do this using the jekyll-redirect-from plugin?

@delphidabbler delphidabbler self-assigned this May 23, 2022
@delphidabbler delphidabbler added the enhancement New feature or request label May 23, 2022
@delphidabbler
Copy link
Owner Author

It can be done with jekyll-redirect-from.

However the plugin will create 200+ numbered .html files in the root directory. This could cause a problem if there's ever a 404.html custom error page and the number of tips becomes >= 404!

@delphidabbler
Copy link
Owner Author

It may be better to rename tips as tip: it feels more intuitive to me to request tips.delphidabbler.com/tip/42 than tips.delphidabbler.com/tips/42.

Another possibility is to rename tips as id.

If tips does get renamed we would need to add a

redirect_from:
  - /tips/xxx

statement to every tip's front matter, where xxx is the tip number.

@delphidabbler
Copy link
Owner Author

delphidabbler commented Sep 13, 2022

Another possibility may be to use a query string for the tip id, e.g. tips.delphidabbler.com/?t=42.

Maybe an anchor could be used instead: tips.delphidabbler.com/#42

But then the main index.html would have to check for the query string or anchor using Javascript and either redirect to the tip page if there's a query string or display the home page if not.

Neither approach looks pretty!

@delphidabbler delphidabbler added the considering Considering or investigating the issue label Sep 25, 2022
@delphidabbler delphidabbler changed the title Redirect URLS in form /<n> to /tips/<n> Redirect URLS in form /<n> to /tips/<n> Oct 14, 2022
@delphidabbler
Copy link
Owner Author

Yet another possibility is to

  1. Rename tips directory to tip as suggested above

  2. Add the required

    redirect_from:
      - /tips/xxx

    front matter to redirect from tips.

  3. Add a further entry to the redirect_from front matter:

    redirect_from:
      - /tips/xxx
      - /t/xxx

    to add support for urls of the form tips.delphidabbler.com/t/xxx.

This way all the following forms of URL would be valid:

  1. tips.delphidabbler.com/tip/xxx (the canonical form)
  2. tips.delphidabbler.com/t/xxx (the shorthand form)
  3. tips.delphidabbler.com/tips/xxx (the old style form)

Charging the canonical form from tips.delphidabbler.com/tips/xxx to tips.delphidabbler.com/tip/xxx might give Google's canonical form algorithm a headache for a while though!

@delphidabbler delphidabbler moved this to Considering in Delphi Tips Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
considering Considering or investigating the issue enhancement New feature or request
Projects
Status: Considering
Development

No branches or pull requests

1 participant