Skip to content

fix(sharing): encode share urls and add optional utm tags - #2336

Merged
markdumay merged 5 commits into
mainfrom
fix/2329-share-url-utm
Nov 6, 2026
Merged

markdumay merged 5 commits into
mainfrom
fix/2329-share-url-utm

Conversation

@markdumay

Copy link
Copy Markdown
Collaborator

Closes #2329

Summary

Share links are now built by a new utilities/GetShareURL.html partial, called from page/sharing.html.

  • Optional UTM tags. A new [sharing.utm] table (enabled, medium, campaign, webshare-source) appends utm_source, utm_medium and utm_campaign to the shared page URL. It is off by default, so no existing site changes its URLs on upgrade. Each provider may set utm-source; the default is its anchorized name, and the default copy-link provider uses clipboard.
  • Correct encoding. For providers that open a URL, {url} and {title} are each query-escaped, with %20 for spaces (never +). A page URL with a query string no longer breaks the provider's url= parameter. Clipboard providers get the raw URL, so the copied link stays readable.
  • Current provider endpoints. X uses https://x.com/intent/post?url={url}&text={title}. WhatsApp uses https://wa.me/?text={title}%20{url}, which also works in a desktop browser without the app.

Tests

tests/templates/layouts/_partials/tests/share-url.html asserts 24 rendered share URLs, covering:

  • encoding of the URL and title
  • UTM on and off
  • an existing query string
  • clipboard rawness
  • the web share data-sharing-url

Red on main, green on this branch. pnpm test passes from a clean cache.

The combined branch with #2330 passes the full suite. A downstream site built against it emits correctly encoded, UTM-tagged links for every provider, with no UTM in og:url, the canonical URL or JSON-LD.

Documentation follows in gethinode/docs (#2331).

🤖 Generated with Claude Code

markdumay and others added 5 commits November 6, 2026 05:10
Share links are now built by utilities/GetShareURL.html. An opened provider gets {url}
and {title} query-escaped, with spaces as %20. Before, {url} went in unescaped, so a page
URL with a query string broke the provider's url parameter, and {title} carried spaces
as +. A clipboard provider still copies the raw page URL.

A new [sharing.utm] section, off by default, appends utm_source, utm_medium and
utm_campaign to the shared page URL. A provider sets utm_source through an optional
utm-source, defaulting to its anchorized name; the web share button uses
webshare-source. An empty campaign is left out.

The Twitter provider becomes X with the x.com post intent, and WhatsApp moves from the
whatsapp:// scheme to wa.me, in the theme and example site defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No earlier case put a space into {url}, so none reached its %20 rewrite; this one does, with
a query string the provider must receive as one parameter. Also drop an unverified claim from
the GetShareURL comment about how every provider decodes %20.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before this branch every provider had {title} replaced, a clipboard one included. The
clipboard branch of GetShareURL only replaced {url}, so a copied "{title}: {url}" kept a
literal {title}. It now gets the raw title, as it gets the raw url.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The copy-link provider is named "email" for its accessible label, so its UTM source
defaulted to "email" and copied links would be reported as email traffic. It now sets
utm-source = "clipboard" in the theme and example site defaults. The template tests read
the theme's params.toml as data and assert the shipped provider.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rces

The template tests now read the theme's params.toml and assert that UTM tagging ships
disabled and that the X and WhatsApp urls are the intended ones. A two-word provider name
is asserted to be anchorized, not only lowercased. The GetShareURL header now says source
falls back to the webshare-source of the UTM settings in use, which a passed utm dict sets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit f4ab83c
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/6aedc333296021ae321f25ce
😎 Deploy Preview https://deploy-preview-2336--gethinode-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@markdumay
markdumay enabled auto-merge November 6, 2026 12:08
@markdumay
markdumay merged commit b1c8b9a into main Nov 6, 2026
17 checks passed
@markdumay

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 3.52.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encode share URLs, add opt-in UTM parameters, and update the X and WhatsApp defaults

1 participant