Skip to content

lnk add

Add a redirect rule. By default the rule goes into static.lnk with a 301 status. Use --dynamic to target dynamic.lnk, and pass a status code as the third argument to override the default.

$ lnk add /path https://destination [status]

Usage

$ lnk add /github https://github.com/bhdicaire
Added to static.lnk: /github → https://github.com/bhdicaire  301

$ lnk add /linkedin https://linkedin.com/in/bhdicaire 301
Added to static.lnk: /linkedin → https://linkedin.com/in/bhdicaire  301

$ lnk add --dynamic /summit https://summit.example.com/2025 302
Added to dynamic.lnk: /summit → https://summit.example.com/2025  302

Options

OptionDefaultDescription
--staticAdd to static.lnk
--dynamicAdd to dynamic.lnk instead
--status CODE301HTTP redirect status code
--comment TEXTPrepend a # comment above the rule
--dry-runPrint what would be added without writing

Status codes

CodeNameWhen to use
301Moved PermanentlyStable links you won’t change
302Found (temporary)Campaign links, A/B tests
307Temporary RedirectPreserves request method
308Permanent RedirectPreserves request method permanently

Examples

# Add a permanent link to static.lnk
lnk add /blog https://blog.example.com

# Add a temporary campaign link to dynamic.lnk with comment
lnk add --dynamic --comment "Q2 campaign, expires 2025-06-30" \
    /summer https://store.example.com?promo=summer 302

# Preview without writing
lnk add --dry-run /test https://example.com

Duplicate paths

lnk add will warn you if the path already exists in either link file, and ask for confirmation before overwriting.
Edit this page Last modified: