NIP-NOSTR-2-WEB
Canonical Web URLs for Replaceable Nostr Events
draft optional
Abstract
This NIP defines a standard mechanism for addressable and replaceable Nostr events (kind:30000-39999 and kind:10000-19999, such as NIP-23 long-form articles) to declare their original, authoritative HTTP(S) web URL using an indexed r tag with a canonical marker.
This enables web-based Nostr clients and gateways to inject HTML <link rel="canonical"> tags when rendering events, providing search engines with a strong deduplication signal so the author's original web page is selected as the primary version in search results.
Motivation
Because Nostr events are public and replicated across many relays, a single long-form article (kind:30023) or addressable resource is often rendered into HTML by numerous independent web clients and gateways (e.g., YakiHonne, Habla, njump, Highlighter).
When an author publishes an article on their own web domain (e.g., https://jotstr.com/my-article) and simultaneously syndicates it to Nostr, search engines indexing the web encounter dozens of identical copies across third-party Nostr gateways. While search engines do not penalize non-deceptive duplicate content, they automatically cluster identical pages and filter out all but one version in search results. Without an explicit canonical signal, search engines frequently select a higher-authority Nostr web gateway over the author's personal domain, effectively hiding the original site from search traffic.
By embedding an indexed canonical URL reference directly inside the signed Nostr event, authors can instruct web-based Nostr clients to output <link rel="canonical">, providing a strong signal to search engines to consolidate indexing properties and display the author's preferred web URL in search results.
Prior Art and Distinction
Relation to PR #856 (2023)
A previous proposal (PR #856) suggested adding a dedicated canonical tag to NIP-23 and NIP-52. Reviewer feedback raised concerns about tightly coupling Nostr events to single webpages that might rot, and noted that a standard ["r", "<url>", "canonical"] tag could already express this relationship without a new tag name. This NIP formalizes that exact ["r", "<url>", "canonical"] convention while directly resolving the architectural objections raised in #856:
- Replaceable/Addressable Events Only: By restricting usage to replaceable events, authors are never permanently locked into a dead domain or static URL slug.
- Full-Content Equivalence: Prohibits using the tag on teasers or link-drops.
- Verification & Link-Rot Fallbacks: Defines strict NIP-05, bidirectional
<link rel="alternate">, and HTTP reachability rules so gateways never canonicalize to spoofed or dead URLs.
Distinction from NIP-48 (Proxy Tags)
NIP-48 defines the ["proxy", "<id>", "<protocol>"] tag (including "web" and "rss") to indicate that an event was bridged from an external protocol where the content was not natively born on Nostr.
- **Use NIP-48 (
proxy)** when a bridge, bot, or aggregator imports external web/RSS/ActivityPub content into Nostr on behalf of an external source. - **Use this NIP (
["r", "<url>", "canonical"])** when an author natively signs and dual-publishes content to both Nostr and their own website, declaring their preferred web URL for search engine deduplication and reader attribution.
Specification
Supported Event Kinds (Replaceable & Addressable Only)
The canonical reference marker MUST only be used on addressable / parameterized replaceable (30000 <= kind < 40000) or replaceable (10000 <= kind < 20000) events.
It MUST NOT be used on regular immutable events (such as kind:1 notes), because web domains and URL structures change over time; an immutable event pointing to an expired or migrated URL would create permanent broken canonical links across the network.
Common addressable event kinds suited for canonical web URLs include:
| Kind | NIP | Description |
|---|---|---|
30023 | NIP-23 | Long-form Content (blog posts, essays, articles) |
30818 | NIP-54 | Wiki Articles and knowledge base pages |
30402 | NIP-99 | Classified Listings and e-commerce product pages |
30617 | NIP-34 | Git Repository Announcements |
31922 / 31923 | NIP-52 | Date-Based and Time-Based Calendar Events |
34235 / 34236 | NIP-71 | Horizontal and Vertical Video Events |
30311 | NIP-53 | Live Streaming Events |
30040 / 30041 | Custom | Curated Publication Indexes and Sections |
The r Tag Format
To declare an authoritative web URL for a replaceable event, the author MUST include an r (reference) tag in the event's tags array with "canonical" as the third element (marker):
["r", "<https-url>", "canonical"]
- **Element 1 (
"r"):** Standard single-letter reference tag, ensuring relays automatically index the URL for reverse lookups ({"#r": ["<https-url>"]}). - **Element 2 (
"<https-url>"):** MUST be a valid, absolutehttps://(orhttp://) URL pointing to the author's preferred web publication. It SHOULD omit tracking parameters (e.g.,utm_*) and fragment identifiers (#). - **Element 3 (
"canonical"):** Marks this specific URL reference as the authoritative canonical source of the event's content, distinguishing it from ordinary citations or links within the body.
An event MUST NOT contain more than one r tag with the "canonical" marker. If multiple are present, clients MUST only respect the first one.
Content Equivalence Requirement
Authors MUST only attach a canonical marker when the Nostr event contains the complete equivalent body content of the target web URL.
It MUST NOT be used on teaser posts, summaries, link-drops, or commentary that merely links to an external article, as search engines ignore <link rel="canonical"> signals when the page body does not closely match the canonical target.
Example Event (NIP-23 Long-Form Content)
{
"id": "...",
"pubkey": "...",
"created_at": 1729340000,
"kind": 30023,
"tags": [
["d", "my-awesome-article"],
["title", "My Awesome Article"],
["published_at", "1729340000"],
["r", "https://jotstr.com/my-awesome-article", "canonical"],
["r", "https://example.com/referenced-study"]
],
"content": "Full markdown content of the article...",
"sig": "..."
}
Implementation Guidelines for Web Clients & Gateways
1. Search Engine Attribution (<link rel="canonical">)
When a web-based Nostr client, gateway, or SSR (Server-Side Rendered) portal renders an addressable Nostr event into an HTML document accessible to web crawlers, it SHOULD check for a verified ["r", "<url>", "canonical"] tag.
If verified and reachable, the web client SHOULD inject a standard HTML canonical link element into the <head> of the rendered page:
<!DOCTYPE html>
<html>
<head>
<title>My Awesome Article</title>
<link rel="canonical" href="https://jotstr.com/my-awesome-article" />
</head>
<body>
...
</body>
</html>
2. Reverse Lookup via Relays
Because the URL is stored in an indexed single-letter r tag, browser extensions and web clients visiting https://jotstr.com/my-awesome-article can query Nostr relays to discover the corresponding Nostr event even if the web page does not embed HTML discovery tags:
["REQ", "sub_id", {"kinds": [30023], "#r": ["https://jotstr.com/my-awesome-article"]}]
Clients performing a reverse lookup via #r MUST filter the returned events locally to ensure the matching r tag includes the "canonical" marker at index 2 and passes verification.
Security, Verification, and Edge Cases
Because any Nostr keypair can sign an event containing any URL in an r tag, clients and web gateways MUST NOT blindly trust an unverified canonical marker. Failure to verify ownership and URL validity exposes gateways and users to phishing, SEO hijacking, link rot, and Server-Side Request Forgery (SSRF).
1. Anti-Phishing (NIP-05 Domain Verification)
Malicious actors may publish copied articles with a canonical URL pointing to a phishing or malware domain so users click "Originally published at..." links in Nostr clients.
- Clients SHOULD verify that the event author's verified NIP-05 identifier domain (
[email protected]) matches the hostname of the canonical URL (https://jotstr.com/...) before rendering trusted source badges or clickable canonical attribution links.
2. Anti-Hijacking (Bidirectional <link rel="alternate"> Handshake)
A spammer may copy a legitimate Nostr-native article onto a third-party website and republish the event under their own keypair with a canonical tag pointing to their scraper site, or point their event to a victim's domain.
- To cryptographically prove bidirectional ownership between the web page and the Nostr event, the origin web page SHOULD implement HTML Nostr Discovery in its
<head>:
<link rel="alternate" href="nostr:naddr1..." />
- When a Nostr client or gateway fetches the target web page and confirms that its
<link rel="alternate" href="nostr:...">decodes to the exact samepubkey,kind, anddtag (vianaddr) as the Nostr event claiming that URL ascanonical, bidirectional ownership is proven even if the author does not use NIP-05.
3. Link Rot Prevention (URL Existence Check)
Web domains expire or change URL slugs over time. If a Nostr web gateway injects <link rel="canonical"> pointing to a dead (404 or unreachable) URL, search engines may struggle to index the surviving Nostr copy.
- Before rendering
<link rel="canonical">or displaying a canonical link to users, gateways SHOULD verify that the target URL is reachable and returns an HTTP200 OKstatus (and optionally verify the<link rel="alternate">tag during the same request). - Verification results SHOULD be cached by the gateway (e.g., for 24–72 hours) so subsequent page views do not trigger repeated outbound HTTP checks. If the URL returns a
4xx/5xxerror or times out, the gateway MUST omit the<link rel="canonical">tag and serve its own URL as canonical.
4. SSRF (Server-Side Request Forgery) Mitigation
When a Nostr web gateway or backend service performs HTTP requests to verify URL existence or check <link rel="alternate"> tags, attackers may submit internal network addresses (e.g., http://127.0.0.1:8080, http://localhost, or cloud metadata endpoints like http://169.254.169.254).
- Strict SSRF Warning: Backend services fetching
canonicalURLs MUST validate the parsed URL and resolved DNS IP addresses before connecting: - Only allow
https://(or explicitly permittedhttp://) schemes on standard ports (80,443). - Block all private, loopback, link-local, and reserved IPv4/IPv6 ranges (
127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16,::1,fc00::/7) both on initial resolution and across any HTTP301/302redirects. - Enforce strict request timeouts (e.g., 3–5 seconds) and maximum response body read limits (e.g., only reading the first 64 KB of HTML to parse the
<head>).