From e0d3522c4150296d8f36b6d16044a744f88ab0e6 Mon Sep 17 00:00:00 2001 From: Guanzhou Song Date: Thu, 30 Jul 2026 12:43:25 -0400 Subject: [PATCH] Add social-share metadata and an Atom feed to the blog The Jekyll layout's head had only title, description, and theme-color: sharing any blog post on X, LinkedIn, or Discord rendered a bare link with no card, and the blog had no feed for aggregators or readers. - og:/twitter: tags in the shared layout, using the post's cover image when present and the site social card otherwise, with og:type article on dated posts and website elsewhere. - A hand-rolled Atom feed at /blogs/feed.xml built from a Liquid template, advertised via a rel=alternate link. A template instead of jekyll-feed avoids a Gemfile.lock regeneration, which cannot be done on machines without local bundler access. - site.url is now set, which absolute_url and the feed's permanent entry IDs both require. The feed opts out of the site-wide layout default with layout: null; without it the config's defaults would wrap the XML in the HTML shell. --- blogs/_config.yml | 3 ++- blogs/_layouts/default.html | 27 +++++++++++++++++++++++++++ blogs/feed.xml | 28 ++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 blogs/feed.xml diff --git a/blogs/_config.yml b/blogs/_config.yml index f9503d1..6201334 100644 --- a/blogs/_config.yml +++ b/blogs/_config.yml @@ -1,7 +1,8 @@ title: DocumentDB Blog description: Insights, updates, and deep dives into the world of document databases and open-source innovation. baseurl: /blogs -url: "" +# Absolute host for og:url, og:image, and the Atom feed's permanent IDs. +url: "https://documentdb.io" permalink: pretty markdown: kramdown kramdown: diff --git a/blogs/_layouts/default.html b/blogs/_layouts/default.html index 5d49624..ecc6db9 100644 --- a/blogs/_layouts/default.html +++ b/blogs/_layouts/default.html @@ -6,6 +6,33 @@ {% if page.title %}{{ page.title }} ยท {% endif %}DocumentDB + + {% assign social_title = page.title | default: site.title %} + {% assign social_description = page.description | default: site.description %} + {% if page.cover_image %} + {% if page.cover_image contains '://' %} + {% assign social_image = page.cover_image %} + {% else %} + {% assign social_image = page.cover_image | absolute_url %} + {% endif %} + {% else %} + {% assign social_image = site.url | append: '/images/social-card.png' %} + {% endif %} + + + + + + + {% if page.date %} + + {% endif %} + + + + + + diff --git a/blogs/feed.xml b/blogs/feed.xml new file mode 100644 index 0000000..fc596c6 --- /dev/null +++ b/blogs/feed.xml @@ -0,0 +1,28 @@ +--- +# layout: null opts out of the site-wide `layout: default` front-matter +# default, which would otherwise wrap this XML in the HTML shell. +layout: null +permalink: /feed.xml +--- + + + {{ site.title | xml_escape }} + {{ site.description | xml_escape }} + {{ '/' | absolute_url }} + + + {% if site.posts.size > 0 %}{{ site.posts.first.date | date_to_xmlschema }}{% else %}{{ site.time | date_to_xmlschema }}{% endif %} + DocumentDB + {% for post in site.posts %} + + {{ post.title | xml_escape }} + {{ post.url | absolute_url }} + + {{ post.date | date_to_xmlschema }} + {% if post.author %}{{ post.author | xml_escape }}{% endif %} + {% if post.description %}{{ post.description | xml_escape }}{% endif %} + {{ post.content | xml_escape }} + {% for tag in post.tags %}{% endfor %} + + {% endfor %} +