Skip to content

Omit image meta tags when a page has no image - #14

Merged
silveltman merged 1 commit into
mainfrom
fix/og-image-undefined
Sep 30, 2026
Merged

silveltman merged 1 commit into
mainfrom
fix/og-image-undefined

Conversation

@silveltman

@silveltman silveltman commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Pages without a resolvable image rendered og:image, og:image:url, og:image:secure_url and the JSON-LD logo URL as https://silveltman.nlundefined, plus empty image type, size and alt tags.

  • The og:image tags and the JSON-LD logo are now only rendered when the image resolves. og:image:alt is only rendered when there is alt text.
  • Pages still inherit the default image (/sil-veltman.jpg) from the index layout, so today every page keeps its image.

Verification

  • Built HTML of main and this branch is identical (only sitemap lastmod differs).
  • With the image temporarily removed from the index layout, no meta tag or JSON-LD contains undefined and the image tags are left out.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Social sharing metadata now uses the processed image URL and its dimensions and format. Image metadata and structured-data logos are omitted when no processed image is available, and image alt text is included only when provided. This prevents incomplete image details from appearing in page metadata.

Pages without a resolvable image rendered og:image, the JSON-LD logo URL
and related tags as https://silveltman.nlundefined. The tags are now left
out in that case. Pages still inherit the default image from the index
layout, so the current output does not change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for silveltman ready!

Name Link
🔨 Latest commit 2dd353f
🔍 Latest deploy log https://app.netlify.com/projects/silveltman/deploys/6abd7d28488e920007f50668
😎 Deploy Preview https://deploy-preview-14--silveltman.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@silveltman
silveltman marked this pull request as ready for review September 30, 2026 21:20
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 74f5246d-7fbd-4ccf-98b2-bec8089a32b8

📥 Commits

Reviewing files that changed from the base of the PR and between dae14b5 and 2dd353f.

📒 Files selected for processing (1)
  • src/components/layout.astro

Limit details: You’ve used all 10 included reviews currently available.


📝 Walkthrough

Walkthrough

The layout now accepts an optional image prop. When a transformed image exists, it uses its URL, format, and dimensions in Open Graph metadata and uses its URL and dimensions in the Schema.org logo. The Open Graph alt tag appears only when alt text is present.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2dd35

No actionable merge-blocking risk is identified. The change omits image metadata when no image resolves while retaining metadata for resolved images; merge after normal checks pass.

Architecture Summary

Architecture risk: 🔵 Low · up to 2dd35

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (ui) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/components/layout.astro: The image prop is now optional instead of required.
  • observed — Modified behavior in src/components/layout.astro: A shared imageUrl is defined from the transformed image URL, or remains falsy when no transformed image exists.
  • observed — Modified behavior in src/components/layout.astro: Open Graph image tags are now conditional on transformedImage. When present, they use the shared URL and transformed format and dimensions; the alt tag is included only when image.alt exists. Previously the tags were always emitted, with optional-chained image values, and the alt tag was unconditional.
  • observed — Modified behavior in src/components/layout.astro: The Schema.org logo value is now conditional on transformedImage; when present, its URL and dimensions use the transformed image and its alt value comes from image.alt. Previously a logo object was always emitted, with optional-chained transformed-image fields.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: omitting image metadata when no image is available.
Description check ✅ Passed The description directly explains the previous undefined image metadata, the conditional rendering changes, and the verification performed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 1
  • Waived: $0.25 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.


Comment @coderabbitai help to get the list of available commands.

@silveltman
silveltman merged commit 56f191e into main Sep 30, 2026
6 checks passed
@silveltman
silveltman deleted the fix/og-image-undefined branch September 30, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant