A shared URL becomes a preview card only when a crawler can read coherent metadata from the page response. Missing, duplicated, or stale values can give social posts the wrong title, image, or destination even while the page looks normal in a browser.
The Open Graph protocol requires og:title, og:type, og:image, and og:url. A concise og:description and og:image:alt add useful context, while duplicate properties deserve attention because consumers give the first value preference when values conflict.
Inspect the final public response after redirects rather than a CMS editor or local template. A private temporary directory confines the downloaded HTML and image bytes, while the closing live query confirms that the metadata remains readable after those local artifacts are removed.
Steps to check Open Graph tags:
- Create a collision-resistant temporary directory for the downloaded page and image.
$ OG_WORKDIR=$(mktemp -d "${TMPDIR:-/tmp}/open-graph-check.XXXXXX")mktemp creates a new private path instead of reusing or overwriting files in the current directory.
- Fetch the final HTML for the public page with redirects applied.
$ curl --fail --location --silent --show-error --output "$OG_WORKDIR/page.html" https://ogp.me/
https://ogp.me/ is the observed sample URL; the exact public page URL belongs in the same argument. The --fail option makes HTTP 400 and 500 responses fail instead of saving an error page.
- Extract the Open Graph metadata from the downloaded document head.
$ xmllint --html --xpath '//head/meta[starts-with(@property,"og:")]' "$OG_WORKDIR/page.html" <meta property="og:title" content="Open Graph protocol"/> <meta property="og:type" content="website"/> <meta property="og:url" content="https://ogp.me/"/> <meta property="og:image" content="https://ogp.me/logo.png"/> <meta property="og:image:type" content="image/png"/> <meta property="og:image:width" content="300"/> <meta property="og:image:height" content="300"/> <meta property="og:image:alt" content="The Open Graph logo"/> <meta property="og:description" content="The Open Graph protocol enables any web page to become a rich object in a social graph."/>
The XPath selects only meta elements inside head, so escaped Open Graph examples elsewhere in the page do not appear in the result.
- Confirm the og:title value names the intended public page.
- Confirm the og:type value classifies the shared object.
The og:type property describes the object category, such as website or article; it does not identify the page.
- Confirm the og:url value is an absolute canonical URL for the same public page.
- Confirm the og:image value is an absolute URL for the intended preview image.
- Confirm the og:image:alt value describes the visible content of the preview image.
- Store the first declared og:image value from the downloaded document in OG_IMAGE_URL.
$ OG_IMAGE_URL=$(xmllint --html --xpath 'string(//head/meta[@property="og:image"][1]/@content)' "$OG_WORKDIR/page.html")
The variable now contains the image URL extracted from the reader's saved page rather than a separate sample asset.
- Download the derived Open Graph image with a GET request.
$ curl --fail --location --silent --show-error --output "$OG_WORKDIR/og-image" --write-out '%{http_code} %{content_type}\n' "$OG_IMAGE_URL" 200 image/pngcurl uses GET by default, follows redirects, and saves the response body as og-image. Expect HTTP 200 with an image/ response type.
- Identify the downloaded response body from its file signature.
$ file --brief --mime-type "$OG_WORKDIR/og-image" image/png
An image/ MIME type confirms that the saved GET body contains recognized image data. HTML, text, or an empty response fails this check.
- Remove the two verification files from the private temporary directory.
$ rm -- "$OG_WORKDIR/page.html" "$OG_WORKDIR/og-image"
- Remove the empty private temporary directory.
$ rmdir -- "$OG_WORKDIR"
rmdir refuses to remove the path if an unexpected file remains inside it.
- Fetch the live page into shell memory after the private directory is removed.
$ OG_LIVE_HTML=$(curl --fail --location --silent --show-error https://ogp.me/)
- Confirm the live Open Graph title remains readable after cleanup.
$ xmllint --html --xpath '//head/meta[@property="og:title"][1]' - <<< "$OG_LIVE_HTML" <meta property="og:title" content="Open Graph protocol"/>