Skip to content
arran4Public

About

Go CLI and library for extracting, validating, editing and visualizing website metadata, including Open Graph, Twitter Cards, JSON-LD and App Links.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

255 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

header

Header Project Card

header is a Go command-line application and library that extracts human-readable metadata from a given URL. It scrapes OpenGraph information, Twitter cards, JSON-LD, AppLinks, and YouTube specifics (watch time, video IDs, titles), displaying them cleanly in the terminal.

Documentation

Developer documentation — getting started, how-to guides, concepts, CLI reference and contribution guidance. The site deploys from main through GitHub Pages Actions; see docs/ for its source.

Prerequisites and Supported Platforms

  • Build targets: Linux and Windows on amd64, arm64 and 386; macOS on amd64 and arm64.
  • Building from Source: Requires Go 1.26 or higher.
  • Go Library: Importable as github.com/arran4/header for embedding metadata extraction directly into Go applications.

Installation

GitHub Releases

Download binaries for Linux, macOS and Windows, or Linux packages, from the GitHub releases page. The latest published version is v0.0.6; each release includes checksums.txt for verifying downloaded assets.

Homebrew (not yet published)

There is not currently a header cask in the arran4/homebrew-tap repository. Until one is published, install from GitHub Releases or use go install.

Go install

go install github.com/arran4/header/cmd/header@latest

To pin the published v0.0.6 version instead of tracking the latest release:

go install github.com/arran4/header/cmd/header@v0.0.6

Commands

show / extract (default)

Extracts human-readable metadata from a given URL. Since v0.0.6, the default is a richer, provenance-aware overview; use --style quick for the previous compact presentation.

header https://example.com/page
header extract https://example.com/page
header extract --style quick https://example.com/page

Illustrative, abridged default output (based on an offline test fixture; actual metadata depends on the page):

URL: https://example.com/page
Canonical URL: https://example.com/canonical-url

Title (HTML):
  Example Page

Social Sharing:
  OpenGraph Type: website
  Twitter Card: summary

Cover Images:
  https://example.com/image.jpg (OpenGraph)

Structured Data (JSON-LD):
  Type: WebPage

Discovery Links:
  Icon: https://example.com/favicon_32x32.png (32x32)

Output Formats The tool supports multiple output formatting templates using the --style flag:

  • default: Rich metadata overview with provenance, source differences, social cards, media, structured data, and discovery links.
  • quick: Compact metadata summary grouping titles, descriptions, and cover images by source (the previous default).
  • all_fields: Full detailed format printing all captured metadata grouped logically.
  • all_fields_plain: Full detailed plain text format without terminal colors.
  • html: Deterministic synthetic HTML <head> representation.
  • json: Raw extracted metadata as formatted JSON.
  • discord: A format tailored for Discord metadata embedding.
  • jsonld: Extracted JSON-LD structured data.
  • opengraph: OpenGraph protocol metadata only.
  • twitter: Twitter card metadata only.

Discover and export available templates:

header styles
header style export quick
header extract --style quick https://example.com
header extract --style-file ./custom.tmpl https://example.com

Example of retrieving all fields in JSON:

header extract --style json https://example.com

Display Cover Images The --show-image flag will download the image and use your system's default image viewer (xdg-open, open, or start) to display it.

header extract --show-image https://example.com/some/article

Experimental Shiny UI: You can build the app with the shiny tag to display the image using an experimental UI window:

go build -tags shiny ./cmd/header
./header extract --show-image https://example.com/some/article

Test Diagnostics If you want to debug what metadata a site is missing, you can use --test:

header extract --test https://example.com

edit

Edits HTML file head/meta fields.

header edit head -S '<link rel="canonical" href="https://example.com/"/>' index.html
header edit meta -s "new value" "description" index.html

The edit command operates in two modes: head and meta.

  • header edit head [flags] <file> targets the root <head> block, allowing you to manipulate standard HTML links and elements.
  • header edit meta [flags] <name> <file> specifically targets a <meta name="..."> or <meta property="..."> tag for modification.

Options:

  • -s: set (removes all existing occurrences of this tag and inserts the new one).
  • -S: add to set (appends a new one, does not remove existing tags).
  • -r: replace (replaces exactly 1 existing value).
  • -n: replace number x (only works with -r, specifies which index to replace).

Use - as the filename to read from stdin and write to stdout, which is useful for chaining in pipes.

trace-redirects

Traces URL HTTP standard redirects as well as HTML meta-refresh redirects.

header trace-redirects https://example.com/redirect

Customization flags include --store-cookies, --redirect-limit, --update-referer, and --redirect-delay.

verify

Checks all URLs and other details; a subset of lint rules mostly concerned with valid info (URL reachability and image validity).

header verify https://example.com

lint

Lints the metadata of a URL.

header lint https://example.com
header lint --list all https://example.com
header lint --rule twitter,opengraph https://example.com

lint-rule-lists

Lists available lint rule lists.

header lint-rule-lists

lint-rules

Lists available lint rules.

header lint-rules

card

Exports a "card" (as an image) including the image, description, and metadata from a URL. Output can be to a file, clipboard, or stdout (specify an output destination subcommand: file, clipboard, or stdout).

header card file --out card.png https://example.com
header card file --require-cover --quality-report report.json --out card.png https://example.com
header card stdout https://example.com > card.png
header card clipboard https://example.com

Card flags:

  • --require-cover: Fails generation if no usable cover image could be loaded. In default mode, a placeholder is rendered.
  • --quality-report <path>: Writes machine-readable card quality JSON diagnostics.
  • --retry-attempts: Number of HTTP attempts for idempotent requests (default: 3; 1 disables retries).
  • --retry-delay: Initial retry delay (default: 250ms).
  • --retry-max-delay: Maximum retry delay cap (default: 5s).
  • --timeout: Maximum total page fetch timeout (default: 20s).
  • --image-timeout: Image download timeout (default: 10s).

Cover image candidates (og:image, og:image:secure_url, and twitter:image) are tried in priority order with automatic fallback upon HTTP errors or decode failures. Piping via card stdout outputs only pure PNG binary data, directing human review diagnostics to stderr.

view

Views images or icons from a URL (positional syntax: header view <viewType> <url>).

header view image https://example.com/image.png
header view icon https://example.com

httpretty

Fetches a URL and prints HTTP requests and responses using httpretty.

header httpretty https://example.com

Development & Testing

See AGENTS.md for contribution and generated-file contracts.

Run unit, integration, and race tests using:

go test -race ./...

Use golangci-lint v2.15.0, matching CI, to run lint checks:

golangci-lint run

To regenerate CLI command definitions:

go generate ./...

The generator is pinned as a Go tool dependency in go.mod. The generation notes explain the small main-template overlay and deterministic provenance settings.

License

This project is licensed under the MIT License; see LICENSE and third-party notices. Fetched website content and third-party assets retain their owners’ rights. See SECURITY.md before using the fetcher in a privileged service.

About

Go CLI and library for extracting, validating, editing and visualizing website metadata, including Open Graph, Twitter Cards, JSON-LD and App Links.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages