Hasty Briefsbeta

Microformats – building blocks for data-rich web pages

3 days ago
  • #microformats
  • #structured-data
  • #web-development
  • Microformats 2 (mf2) is used to mark up profiles, posts, events, and other data on personal sites.
  • To parse mf2 data, choose a parser from available libraries or use online tools like php-mf2 sandbox or pin13.net.
  • When fetching and parsing mf2 data, ensure the parser uses the effective URL for correct relative URL resolution.
  • Store raw HTML and derived data for future re-parsing, but skip intermediate canonical JSON to save space.
  • Parsed mf2 data contains 'items' (top-level structures), 'properties', and 'children' (nested structures).
  • Property values in mf2 can be plain strings, embedded HTML, img/alt structs, or nested microformats.
  • Always handle property values flexibly—never assume a specific format (e.g., plaintext vs. HTML).
  • Use helper functions to extract plaintext, HTML, or image URLs from mf2 properties safely.
  • For nested microformats, handle cases where expected structures may be missing or replaced with alternatives.
  • Leverage existing algorithms (e.g., authorship, representative h-card) for common mf2 consumption tasks.
  • Sanitize and validate mf2 data to prevent XSS and other security risks before storing or displaying.
  • Test your mf2 parser with real-world data to ensure compatibility with diverse publishing methods.