delphi-tips
delphi-tips copied to clipboard
Redirect URLS in form `/<n>` to `/tips/<n>`
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?
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!
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.
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!
Yet another possibility is to
-
Rename
tipsdirectory totipas suggested above -
Add the required
redirect_from: - /tips/xxxfront matter to redirect from
tips. -
Add a further entry to the
redirect_fromfront matter:redirect_from: - /tips/xxx - /t/xxxto add support for urls of the form
tips.delphidabbler.com/t/xxx.
This way all the following forms of URL would be valid:
tips.delphidabbler.com/tip/xxx(the canonical form)tips.delphidabbler.com/t/xxx(the shorthand form)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!