Skip to content

Commit 5ebef74

Browse files
docs: short URLs guide for website (asyncapi#2129)
Co-authored-by: Vishvamsinh Vaghela <vaghelavishvamsinh11111@gmail.com> Co-authored-by: V Thulisile Sibanda <66913810+thulieblack@users.noreply.github.com>
1 parent 5fb3b8a commit 5ebef74

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Create Short URLs for the AsyncAPI Website
3+
description: Learn how to create short, memorable redirect links for the AsyncAPI website using the Netlify-powered `_redirects` file.
4+
weight: 10
5+
---
6+
7+
## Introduction
8+
9+
Short URLs make it easier for users to access commonly shared AsyncAPI resources (e.g., `asyncapi.com/slack` instead of long invite links). To avoid conflicts with existing routes (like `/docs`, `/community`, etc.), all short URLs **must use the `/s/` path prefix**. These short links are powered by Netlify server-side redirects using the `_redirects` file, ensuring fast, reliable, and CDN-level redirection.
10+
11+
## Understanding the `_redirects` file
12+
13+
The `_redirects` file is a plain text file that defines redirect rules for the AsyncAPI website. Netlify uses this file during deployment and applies the redirects at the CDN (edge) level, meaning the redirect occurs before the page loads, ensuring high performance and a better user experience.
14+
15+
### File Location
16+
17+
For the AsyncAPI website, the `_redirects` file is located at: `public/_redirects`
18+
19+
### How Redirects Are Processed
20+
21+
Netlify reads the `_redirects` file top to bottom and applies the first matching rule, so the order of rules matters.
22+
23+
## Defining a Short URL Rule
24+
25+
Each short URL must start with `/s/` to avoid conflicts with existing site paths. Write each redirect rule on a single line, with space-separated values:
26+
27+
```text
28+
/s/short-path https://destination.url status
29+
```
30+
31+
Where `status` can have one of the following values:
32+
33+
- 301: Permanent - for links that remain unchanged.
34+
- 302: Temporary - for links that may change in the future.
35+
36+
### Examples
37+
38+
```text
39+
/s/slack-invite https://asyncapi.com/slack 302
40+
/s/modelina /tools/modelina 301
41+
/s/github https://github.com/asyncapi 301
42+
```
43+
44+
## Steps to Add a New Short URL
45+
46+
1. Navigate to the [`public/_redirects` file](https://github.com/asyncapi/website/blob/master/public/_redirects) in the AsyncAPI website repository ([local setup guide](https://github.com/asyncapi/website?tab=readme-ov-file#run-locally)).
47+
48+
2. Add a new redirect rule on a separate line. You may include a comment above the rule for clarity. For example:
49+
```text
50+
# Permanent redirect to the main Studio app
51+
/s/asyncapiv2 https://raw.githubusercontent.com/asyncapi/asyncapi/2.0.0/examples/2.0.0/streetlights.yml 301
52+
```
53+
54+
3. Raise a PR with a clear description of the changes ([contribution guide](https://github.com/asyncapi/website/blob/master/CONTRIBUTING.md)).
55+
56+
---

0 commit comments

Comments
 (0)