Redirect "/id/*/" to the actual post link

#1

Hi!

The documentation says it’s possible to get specific post by its ID using the “get” helper:

{{#get "posts" id="2" include="tags,authors" as |post|}}
    {{#post}}
        {{title}}
    {{/post}}
{{/get}}

Can I access the post ID in the redirects.json? I want to make it possible to use short links for posts. For example, if someone follows the link /id/185/, then this user should be redirected to the /actual-post-link/ (assuming that this post has ID 185).

Thanks!

#2

There is no access to the post ID in redirects.json - it’s a static map, there is no interpolation done of values. The “short” URLs may also not be particularly short, Ghost uses ObjectIDs which are 24char values like 507f1f77bcf86cd799439011.

If you need short URLs for a specific reason I would suggest using a URL shortening service which will also typically have a short hostname.

closed #3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.