willcheung

publishing-to-blogger

Use when creating, publishing, or updating blog posts on Blogger. Triggers on "blog post", "publish to Blogger", "write a post", "update blog", or any Blogger API task.

willcheung 0 Updated 2mo ago
GitHub

Install

npx skillscat add willcheung/calautobot-blog

Install via the SkillsCat registry.

SKILL.md

Publishing to Blogger

Overview

Publish blog posts to Blogger via the Blogger API v3 using OAuth2 credentials with token caching. Posts use a reusable HTML template structure.

Prerequisites

  • OAuth2 credentials: /Users/willcheung/Downloads/credentials.json (Google "installed app" type)
  • Cached token: /Users/willcheung/Downloads/blogger_token.json (auto-created on first auth)
  • Blog ID: 8721638515524520502 (Cal Autobot Blog)
  • Python venv: /tmp/blogger-migrate/ with google-auth, google-auth-oauthlib, google-api-python-client
  • Blog posts repo: /Users/willcheung/dev/calautobot-blog/content/posts/

If the venv doesn't exist, create it:

python3 -m venv /tmp/blogger-migrate
/tmp/blogger-migrate/bin/pip install google-auth google-auth-oauthlib google-api-python-client

Post HTML Template

<article class="blog-post">
  <figure class="post-hero">
    <img src="IMAGE_URL" alt="description" />
  </figure>

  <p class="byline">
    <em>Researched and written by Cal, AI CEO of CalAutobot</em><br>
    <time datetime="YYYY-MM-DD">Month D, YYYY</time> • N min read
  </p>

  <section class="intro">
    <h2>Intro Heading</h2>
    <p>Opening text...</p>
  </section>

  <section class="content">
    <h2>Section Heading</h2>
    <p>Body text...</p>
    <!-- Repeatable for multiple sections -->
  </section>

  <!-- Quotes: text directly in blockquote, NO inner <p> tags (causes double-quote spacing bug) -->
  <blockquote>Quote text here<br>— Attribution</blockquote>

  <!-- X/Twitter embeds: use oEmbed API, not raw blockquotes -->
  <!-- Fetched via: https://publish.twitter.com/oembed?url=TWEET_URL&omit_script=true -->

  <section class="sources">
    <h2>Sources</h2>
    <ul class="source-list">
      <li><a href="URL">Source name</a></li>
    </ul>
  </section>

  <section class="cta">
    <hr>
    <p><strong>About the author:</strong> ...</p>
    <p class="cta-links">
      <a href="https://twitter.com/CalAutobot">Follow @CalAutobot</a> •
      <a href="https://calautobot.com">Try CalAutobot</a>
    </p>
  </section>
</article>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Workflow

New Post

  1. Draft HTML using template above
  2. Save to calautobot-blog/content/posts/slug-name.html
  3. Run publish.py (in this skill directory) with --action create

Update Post

  1. Run publish.py with --action update --post-id POST_ID

Publishing Script

Use publish.py in this skill directory. Run --help for options.

Known Gotchas

Issue Fix
Double quotes in blockquotes Never wrap blockquote text in "..." — Blogger theme adds its own
Spacing in blockquotes Put text directly in <blockquote>, no inner <p> tags
<script> tags stripped Blogger sometimes strips them; add widgets.js script tag at end of content
X embeds not rendering Use Twitter oEmbed API to fetch full embed HTML; include widgets.js
Token expired Script auto-refreshes from blogger_token.json; delete token file to re-auth
Images need hosting Use GitHub raw URLs or upload to a public host; local paths won't work