From cb1f1ec83e6c490b4bf6a4584d130c450b5a2301 Mon Sep 17 00:00:00 2001 From: Rishi Balakrishnan Date: Fri, 31 Jul 2026 14:32:22 -0400 Subject: [PATCH] Emit at:canonical meta tags per the at-tags proposal Adds with the DID-form AT-URI of the record each page renders (post, profile, feed generator, starter pack), per https://tangled.org/chrisshank.com/at-tags. Lets clients, embedders, and crawlers map our web pages back to their canonical atproto records without scraping URL structures. --- bskyweb/cmd/bskyweb/server.go | 11 ++++++++++- bskyweb/templates/feed.html | 3 +++ bskyweb/templates/post.html | 6 ++++++ bskyweb/templates/profile.html | 3 +++ bskyweb/templates/starterpack.html | 3 +++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go index 70ee06c39..52c9cb699 100644 --- a/bskyweb/cmd/bskyweb/server.go +++ b/bskyweb/cmd/bskyweb/server.go @@ -844,6 +844,11 @@ func (srv *Server) WebPost(c echo.Context) error { // handle is unusable (template strips query/fragment). canonicalURL := bskyPostURL(pv.Handle, rkey.String()) + // DID-form AT-URI of the post record, emitted as + // per the at-tags proposal (https://tangled.org/chrisshank.com/at-tags). + atURI := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", pv.Did, rkey) + data["atURI"] = atURI + if !unauthedViewingOkay { // Provide minimal OpenGraph data for auth-required posts data["requestURI"] = requestURI @@ -861,7 +866,7 @@ func (srv *Server) WebPost(c echo.Context) error { } // then fetch the post thread (with extra context) - uri := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", pv.Did, rkey) + uri := atURI tpv, err := appbsky.FeedGetPostThread(ctx, srv.xrpcc, 1, 0, uri) if err != nil { log.Warnf("failed to fetch post: %s\t%v", uri, err) @@ -944,6 +949,8 @@ func (srv *Server) WebStarterPack(c echo.Context) error { return c.Render(http.StatusOK, "starterpack.html", data) } data["title"] = rec.Name + // DID-form AT-URI from the view (starterPackURI may be handle-form). + data["atURI"] = spv.StarterPack.Uri if srv.cfg.ogcardHost != "" { data["imgThumbUrl"] = fmt.Sprintf("%s/start/%s/%s", srv.cfg.ogcardHost, identifier, rkey) } @@ -1011,6 +1018,7 @@ func (srv *Server) WebProfile(c echo.Context) error { data["profileView"] = pv data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path) data["requestHost"] = req.Host + data["atURI"] = fmt.Sprintf("at://%s/app.bsky.actor.profile/self", pv.Did) // Prefer the handle-form URL so JSON-LD `url` and // match. Template falls back to requestURI @@ -1102,6 +1110,7 @@ func (srv *Server) WebFeed(c echo.Context) error { req := c.Request() data["feedView"] = fgv.View data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path) + data["atURI"] = feedURI return c.Render(http.StatusOK, "feed.html", data) } diff --git a/bskyweb/templates/feed.html b/bskyweb/templates/feed.html index 9a2164ce2..0e69ac633 100644 --- a/bskyweb/templates/feed.html +++ b/bskyweb/templates/feed.html @@ -39,6 +39,9 @@ + {%- if atURI %} + + {% endif -%} {% endif -%} {%- endblock %} diff --git a/bskyweb/templates/post.html b/bskyweb/templates/post.html index 55c101ac7..147ad5a13 100644 --- a/bskyweb/templates/post.html +++ b/bskyweb/templates/post.html @@ -14,6 +14,9 @@ {%- if postView -%} + {%- if atURI %} + + {% endif -%} {%- if requestURI %} {% if canonicalURL %} @@ -75,6 +78,9 @@ {%- elif requiresAuth and profileHandle -%} + {%- if atURI %} + + {% endif -%} {%- if requestURI %} {% if canonicalURL %} diff --git a/bskyweb/templates/profile.html b/bskyweb/templates/profile.html index 82fe91984..5fbcc5ecf 100644 --- a/bskyweb/templates/profile.html +++ b/bskyweb/templates/profile.html @@ -30,6 +30,9 @@ {% endif -%} + {%- if atURI %} + + {% endif -%} diff --git a/bskyweb/templates/starterpack.html b/bskyweb/templates/starterpack.html index 6d9f40073..7e313c213 100644 --- a/bskyweb/templates/starterpack.html +++ b/bskyweb/templates/starterpack.html @@ -5,6 +5,9 @@ {%- if requestURI %} {% endif -%} + {%- if atURI %} + + {% endif -%} {%- if imgThumbUrl %} -- knotmirror 0.0.1