DEV Community

Fernando Paladini
Fernando Paladini

Posted on

Add Dublin Core Metadata to a Static HTML Page with dublin-core-basics

When a static site needs descriptive metadata, it is tempting to copy a long list of meta tags from an old template and hope search engines reward it. That approach is hard to audit and easy to overstate.

The open-source dublin-core-basics repository is a small, readable starting point. It is a static HTML guide that shows the Dublin Core vocabulary in context. The useful lesson today is not that Dublin Core guarantees better rankings. It is how to add a small, explicit metadata profile to an HTML document, then verify what the browser actually receives.

What you will build

You will create a minimal static page with:

  • standard HTML metadata such as description and author;
  • Dublin Core terms expressed as HTML meta elements;
  • a stable identifier and an explicit language value;
  • a repeatable check that reads the document head and reports missing fields.

The example is intentionally small. DCMI maintains a much larger set of metadata terms, and its official HTML guidance explains how Dublin Core metadata can be embedded in HTML and XHTML. Use the current DCMI Metadata Terms specification as the vocabulary reference, and the DC-HTML specification when you need the encoding rules.

Prerequisites

You need:

  • Git;
  • Python 3 for a local static server;
  • a browser or an HTML parser;
  • a page you can edit locally.

The repository is public, non-archived, non-forked, and licensed under MIT. It has no package installation step or runtime dependency. Its default branch is master, so the commands below target the current repository contents rather than a numbered release.

Start from the project

Clone the repository and serve it locally:

git clone https://github.com/paladini/dublin-core-basics.git
cd dublin-core-basics
python -m http.server 8000
Enter fullscreen mode Exit fullscreen mode

Open http://127.0.0.1:8000/ in a browser. The project is a slide-like static guide. Its index.html contains the metadata block near the top of <head>, then explains the same terms in the page body.

The original page is useful as a reference, but some of its wording reflects older assumptions about SEO. Treat it as an example of structure and vocabulary. Check current behavior and current specifications before copying a claim into a production site.

Add a focused metadata block

Here is a smaller profile you can adapt for a documentation page. The term names use the DC. prefix shown by the project and described by DCMI's HTML guidance.

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Deploy a Static HTML Site</title>
  <meta name="description" content="A short guide to deploying a static HTML site.">

  <meta name="DC.title" content="Deploy a Static HTML Site">
  <meta name="DC.creator" content="Example Documentation Team">
  <meta name="DC.subject" content="Static websites">
  <meta name="DC.description" content="A short guide to deploying a static HTML site.">
  <meta name="DC.type" content="Text">
  <meta name="DC.format" content="text/html">
  <meta name="DC.identifier" content="https://docs.example.test/static-site">
  <meta name="DC.language" content="en">
  <meta name="DC.rights" content="https://creativecommons.org/licenses/by/4.0/">
</head>
Enter fullscreen mode Exit fullscreen mode

The ordinary HTML title and description remain important page metadata. The Dublin Core block adds explicit semantics for systems that understand those terms. It does not replace accessible page content, headings, canonical URLs, structured data, or a useful document body.

For a real page, replace the example identifier with the page's canonical URL and use a rights statement that is actually true. Do not copy the repository's historical DC.Date, DC.Rights, or HTTP URLs into a new site without reviewing them. Metadata is part of the page's public claims.

Why the repository uses a guide page

The repository keeps the learning path visible in one index.html file. Each term is introduced, shown as a code sample, and connected to the corresponding DCMI documentation. That makes it easy to inspect the source and compare the rendered page with the metadata it teaches.

The project also demonstrates a practical boundary: metadata is data about a resource, not a substitute for the resource. DC.title can describe a page, but it cannot fix a misleading page title. DC.subject can name a topic, but it cannot make unrelated content relevant. The current DCMI specification is authoritative for term definitions, while the browser and search engine decide what they do with a particular serialization.

Verify the document head

A simple check catches broken names, empty values, and accidental duplication. Save this as check-metadata.py beside your page:

from html.parser import HTMLParser
from urllib.request import urlopen


class MetadataParser(HTMLParser):
    def __init__(self):
        super().__init__()
        self.metadata = {}

    def handle_starttag(self, tag, attrs):
        if tag.lower() != "meta":
            return
        values = dict(attrs)
        name = values.get("name", "").lower()
        content = values.get("content", "").strip()
        if name.startswith("dc."):
            self.metadata.setdefault(name, []).append(content)


parser = MetadataParser()
with urlopen("http://127.0.0.1:8000/") as response:
    parser.feed(response.read().decode("utf-8"))

required = {"dc.title", "dc.creator", "dc.description", "dc.identifier", "dc.language"}
missing = sorted(name for name in required if not parser.metadata.get(name))

if missing:
    raise SystemExit(f"Missing Dublin Core fields: {', '.join(missing)}")

print(f"Verified {len(parser.metadata)} Dublin Core fields")
Enter fullscreen mode Exit fullscreen mode

Run it while the server is active:

python check-metadata.py
Enter fullscreen mode Exit fullscreen mode

Expected output is similar to Verified 9 Dublin Core fields. The exact count depends on how many optional terms you include. This check verifies the HTTP response, not only a local file, so it also catches serving the wrong directory or editing a file that is not deployed.

Common failure modes

Treating metadata as a ranking switch

The repository's historical copy says Dublin Core can improve SEO. That is too broad for a current tutorial. DCMI defines terms and encodings; it does not promise a ranking effect. Keep the metadata accurate because it helps describe and exchange information, not because a tag guarantees visibility.

Copying obsolete examples

The current DCMI terms page is the source of truth for maintained terms. Older tutorials may use outdated URLs, capitalization, scheme patterns, or claims about how consumers interpret a field. Compare every copied example with the current specification.

Publishing empty or contradictory values

An empty DC.description, a stale URL in DC.identifier, or a rights statement that disagrees with the site's license makes the page less trustworthy. Validate values as part of your build or deployment check.

Assuming every consumer reads every term

HTML metadata is available to consumers, but support differs. Test the systems that matter to your project. Keep the visible title, body headings, links, and accessibility information correct even if a consumer ignores Dublin Core.

FAQ

Do I need all 15 classic elements?

No. Start with terms that describe your resource accurately. The DCMI specification now contains more than the original 15-element foundation, so completeness is not the same as usefulness.

Should I use DC.title or dcterms.title?

Follow the syntax and vocabulary required by your consumer. The repository demonstrates the DC. form, while current DCMI documentation describes the maintained terms and their namespaces. Do not mix forms casually in a contract that another system parses.

Does this replace Open Graph or JSON-LD?

No. They solve different interoperability problems. Keep the formats required by your consumers, avoid contradictory values, and make one source of truth generate repeated metadata when possible.

Is the repository a production framework?

No. It is a small static educational guide with bundled front-end assets and no package manager workflow. Use it to understand the markup pattern, then maintain your own page and verification rules.

Takeaway

paladini/dublin-core-basics is most useful as an inspectable example: metadata lives in the HTML head, each term has a defined meaning, and the page can be served without a build system. The safe workflow is to choose a small accurate profile, consult the current DCMI specifications, and verify the served HTML before deployment.

What metadata consumer would you target first in your project, and how would you test that it actually reads the fields you publish?

Disclosure: AI assistance was used to organize and edit this tutorial. Repository behavior, license, current HTML examples, and the linked DCMI specifications were checked against their primary sources before publication.

Top comments (0)