Repository navigation
fix(blog): render canonical tags and fix og:url on blog pages - #205
Merged
Merged
Conversation
og:url was built from the undefined NEXT_PUBLIC_APP_URL env var, producing https://dokploy.com/undefined/blog/<slug>. Blog pages also had no canonical. - Add SITE_URL and getPostCanonicalUrl() (Ghost canonical_url if set, else https://dokploy.com/blog/<slug>; absolute, no query/hash) - Set alternates.canonical + og:url on posts, blog index and tag pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
og:urlon blog posts rendered ashttps://dokploy.com/undefined/blog/<slug>. It was built fromprocess.env.NEXT_PUBLIC_APP_URL, which is not defined, so it became the relative pathundefined/blog/...and was resolved againstmetadataBase./blogand individual posts rendered no<link rel="canonical">.Changes
lib/ghost.ts: addsSITE_URLandgetPostCanonicalUrl(). It uses the post's Ghostcanonical_urlwhen set; otherwise it useshttps://dokploy.com/blog/<slug>. The result is always absolute and has no query string or hash,wwwis normalized to the bare domain, and canonicals pointing tocms.dokploy.comare ignored.alternates.canonicalandog:urlcome from that helper.og:urlarehttps://dokploy.com/blog.https://dokploy.com/blog/tag/<tag>.Verified locally (
next dev, requested with?utm=x)Not in this PR (infra)
cms.dokploy.comcurrently has Ghost private mode enabled. Posts return a 302 to/private/, androbots.txtisDisallow: /. Images under/content/images/still load. The plan is to replace private mode with a 301 redirect from/<slug>/tohttps://dokploy.com/blog/<slug>, set up as a Cloudflare or Ghost redirect rule.www.dokploy.comalready returns a 301 todokploy.com.