-
-
Notifications
You must be signed in to change notification settings - Fork 10
Fix og:url and canonical URLs by creating toplevel_id_clean variable in index.js #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Co-authored-by: cirosantilli <[email protected]>
|
toplevel_id doesn't work well if the target has .html extension |
|
@copilot toplevel_id doesn't work well if the target has .html extension |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.1/css/all.min.css" integrity="sha512-9my9Mb2+0YO+I4PUCSwUYO7sEK21Y0STBAiFEYoWtd2VzLEZZ4QARDrZ30hdM1GlioHJ8o8cWQiy8IAb1hy/Hg==" crossorigin="anonymous" referrerpolicy="no-referrer">{% unless is_index_article %} | ||
| <link rel="canonical" href="https://ourbigbook.com/cirosantilli/{{ toplevel_id }}">{% endunless %} | ||
| <link rel="canonical" href="https://ourbigbook.com/cirosantilli/{{ toplevel_id }}">{% endunless %}{% if is_index_article %} | ||
| <meta property="og:url" content="https://cirosantilli.com">{% else %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot why one points to ourbigbook.com and the other to cirosantilli.com?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The domain difference follows this logic:
- Index articles (homepage):
og:urlpoints tohttps://cirosantilli.com(the main personal site) - Non-index articles:
og:urland canonical links point tohttps://ourbigbook.com/cirosantilli/...(where the content actually lives)
This ensures the homepage social shares point to your main domain while individual articles point to their canonical location on OurBigBook.com. Both URLs now properly strip .html extensions for clean URLs.
Co-authored-by: cirosantilli <[email protected]>
|
@copilot try testing again |
Fixed the issue by adding Liquid Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Don't fix in Liquid, rather fix in index.js with new variable. |
I've tested the changes by building sample pages. The template correctly:
The URL stripping functionality is working as expected. Commit: 053e918 |
…in index.js Co-authored-by: cirosantilli <[email protected]>
Fixed by creating index.js script that patches the OurBigBook library to add |
This PR fixes URL generation for
og:urlmeta tags and canonical links by creating a newtoplevel_id_cleantemplate variable in JavaScript instead of using Liquid filters.Problem
When
toplevel_idcontains.htmlextensions, URLs would be generated as:https://ourbigbook.com/cirosantilli/article-name.htmlBut OurBigBook.com expects clean URLs without extensions:
https://ourbigbook.com/cirosantilli/article-nameThe previous approach used Liquid's
replacefilter, but this was not the preferred solution.Solution
Created
index.jsscript that patches the OurBigBook library to automatically generate atoplevel_id_cleantemplate variable:The template now uses the clean variable directly:
Benefits
index.jsscript acts as a wrapper around the ourbigbook CLIChanges
toplevel_id_cleanvariable{{ toplevel_id_clean }}instead of{{ toplevel_id | replace: ".html", "" }}This ensures proper Open Graph metadata for social media sharing while maintaining clean, consistent URL patterns across the site.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.