diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 212228c..089e2e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,5 @@ jobs: cache: npm - run: npm ci - run: npm run build + - run: npm run check:seo - run: npm run format:check diff --git a/README.md b/README.md index cac8f38..7e8625e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # hausergroup.github.io -The Hauser Group website, built with [Astro](https://astro.build) and published at +The website of the **Hauser Group** (Pharmacoinformatics) at the Department of +Drug Design and Pharmacology, University of Copenhagen, studying how human +genetic variation changes the way G protein-coupled receptors (GPCRs) respond to +drugs. Built with [Astro](https://astro.build) and published at . ## Run it locally @@ -13,21 +16,30 @@ npm run dev ``` The site is then at and reloads as you edit. -`npm run build` builds the production site into `dist/`. +`npm run build` builds the production site into `dist/`, and `npm run check:seo` +verifies sitemaps, canonical links, metadata, Open Graph tags, JSON-LD and +`llms.txt` in `dist/`. `npm run format` formats your changes with Prettier. The **Build site** check -fails on unformatted files, so run it before you push. +fails on unformatted files or failed SEO checks, so run both before you push. ## Where things live -- `src/pages/` — one file per page. `src/pages/people.astro` becomes `/people`. -- `src/data/site.ts` — people, research lines and other content lists. -- `src/layouts/Base.astro` — the page head, header and footer. +- `src/pages/` — one file per page (`src/pages/people/` becomes `/people/`, + plus build-time endpoints for `sitemap.xml`, `robots.txt` and `llms.txt`). +- `src/data/site.ts` — research scales, statement and ways to join. +- `src/data/profiles.ts` — people, roles, portraits and external profile links. +- `src/data/publications.ts` — curated publications with DOIs. +- `src/data/structuredData.ts` — Schema.org JSON-LD builders. +- `src/layouts/Base.astro` — page head, metadata, header and footer. - `src/styles/site.css` — colors, type and components. -- `src/components/` — the logo and the receptor drawing. -- `public/` — files served as-is, such as images and PDFs. +- `src/components/` — the logo, particle receptor and page sections. +- `public/` — files served as-is (`CNAME`, `favicon.svg`, `og-image.png`, + portraits). +- `scripts/check-seo.mjs` — automated build-output SEO verification run in CI. - `astro.config.mjs` — site configuration. - `design/DESIGN.md` — the design choices behind the site. Read it before changing how things look. +- `design/SEO.md` — search discoverability guide and checklist. VS Code will suggest the Astro and Prettier extensions when you open the folder; install them for autocomplete in `.astro` files and formatting from the editor. diff --git a/design/SEO.md b/design/SEO.md new file mode 100644 index 0000000..4a92071 --- /dev/null +++ b/design/SEO.md @@ -0,0 +1,98 @@ +# Search discoverability + +A practical catalogue of actions to help researchers, prospective students, +collaborators, funders and AI search tools find the Hauser Group at +. + +## Ground rules + +- **Static, privacy-first, no analytics scripts.** Do not add Google Analytics, + tracking pixels or cookie banners. Search measurement comes from Google Search + Console and Bing Webmaster Tools (verified via DNS in Cloudflare). +- **Generated, not hand-maintained.** `sitemap.xml`, `robots.txt`, canonical + links, Open Graph tags, Schema.org JSON-LD and `llms.txt` are generated by + Astro at build time from `src/data/*.ts` and verified in CI by + `npm run check:seo`. +- **Verifiable academic facts only.** Publications link to DOIs, news items link + to institutional sources, and statistics match published work. +- **Keep lab SEO and software SEO separated.** Product-specific discovery + (`.pzfx`/`.prism` pages, alternative directories, bio.tools, MCP registries) + belongs on `curvebook.org` and `scikit-opls`, while `hausergroup.org` owns the + lab identity, people, research, publications and recruitment. +- **No gaming.** No keyword stuffing, hidden text, doorway pages or orphaned + near-duplicate pages. + +## Who we want to reach + +| Search intent | Example searches | Target page | +| -------------------------- | --------------------------------------------------------------------------------- | -------------------------------------------------------- | +| Find the lab or PI | "Hauser Group Copenhagen", "Alexander Sebastian Hauser", "pharmacoinformatics KU" | `/`, `/about/`, `/people/alexander-hauser/`, `/contact/` | +| Find a group member | " UCPH", " Hauser group" | `/people/[slug]/`, `/people/`, `/alumni/` | +| Research topics & methods | "GPCR pharmacogenomics", "human genetic variation GPCR drug response" | `/`, `/about/`, `/publications/` | +| Join the lab / collaborate | "GPCR PhD Copenhagen", "computational pharmacology postdoc Denmark" | `/opportunities/`, `/services/`, `/contact/` | +| Find group software | "Hauser group software", "scikit-opls", "CurveBook Hauser" | `/software/` | +| Check papers & awards | "34% approved drugs GPCR Hauser", "DARK-PEP ERC", "NeuroPepX Lundbeck" | `/publications/`, `/news/` | + +Because multiple labs and companies share the name "Hauser Group", always pair +**Hauser Group** with **Pharmacoinformatics**, **GPCR** and **University of +Copenhagen** in titles, descriptions, READMEs and external profiles. + +## Status key + +| Status | Meaning | +| -------- | --------------------------------------------------------------------- | +| Done | Implemented in the site and verified by `npm run check:seo` | +| Ready | Possible now in the repo without external accounts | +| Decision | Needs a maintainer choice before implementing | +| Account | Requires signing in to an external service (Cloudflare, Google, etc.) | + +## 1. Technical foundations + +| Action | Status | Notes | +| ---------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | +| Custom domain (`hausergroup.org`) with HTTPS enforced | Done | Verified on `HauserGroup` org; `www` and `hausergroup.github.io` 301-redirect to `https://hausergroup.org/` | +| Publish only built Astro `dist/` via GitHub Actions | Done | Internal docs (`design/`, `README.md`) are never published or indexed | +| Generated `sitemap.xml` (`src/pages/sitemap.xml.ts`) | Done | Covers all static pages and `/people/[slug]/`, excludes `/404`, verified for exact parity with `dist/` in CI | +| Generated `robots.txt` (`src/pages/robots.txt.ts`) | Done | Points crawlers to `https://hausergroup.org/sitemap.xml` | +| Canonical `` on every indexable page | Done | Emitted in `src/layouts/Base.astro` from `Astro.url.pathname` + `Astro.site` | +| `404.html` with `` and home link | Done | Keeps dead URLs out of search indexes | +| Unique per-page `` | Done | Tailored per static page and auto-generated on `/people/[slug]/`; uniqueness enforced by `npm run check:seo` | +| Open Graph & Twitter summary-card tags + `public/og-image.png` | Done | `1200×630` default card image; square member portraits with `summary` card on `/people/[slug]/` | +| Schema.org JSON-LD (`ResearchOrganization`, `Person`, `SoftwareApplication`, `BreadcrumbList`, `CollectionPage`) | Done | Built in `src/data/structuredData.ts`; `Person` pages link `sameAs` directly to ORCID, Google Scholar, `researchprofiles.ku.dk`, GitHub and LinkedIn | +| Generated `llms.txt` (`src/pages/llms.txt.ts`) | Done | Built from `src/data/*.ts` so AI tools always see accurate people, ORCIDs, papers, software and contact info | +| Automated CI SEO check (`npm run check:seo`) | Done | Runs in `.github/workflows/ci.yml` on every PR | +| Portrait `alt` text on profile pages + explicit `width`/`height` + lazy loading | Done | `alt={person.name}` on `/people/[slug]/`; decorative cards keep `alt=""` next to linked name text | +| Remove orphaned `/research/` duplicate page | Done | Eliminated unlinked duplicate of `` | +| Align `README.md` opening paragraph with canonical lab identity | Done | AI coding agents and GitHub search read READMEs directly | +| Self-host fonts (e.g. Fontsource or local `.woff2`) | Decision | Removes the last external request (`fonts.googleapis.com`) and unlocks custom/indie display fonts beyond Google Fonts | +| Deterministic `` in `sitemap.xml` | Decision | Omitted for simplicity; can be added from git commit timestamps if the site starts changing weekly | + +## 2. Measurement + +| Action | Status | Notes | +| ------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------- | +| Verify `hausergroup.org` in Google Search Console | Account | Add a **Domain property** via Cloudflare DNS `TXT` record and submit `https://hausergroup.org/sitemap.xml` | +| Verify in Bing Webmaster Tools | Account | Import from verified Google Search Console in one click; feeds Bing, DuckDuckGo and AI search integrations | +| Quarterly manual check in AI search tools | Ready | Run a fixed query set across ChatGPT, Claude, Perplexity and Google AI Overviews and verify cited facts | +| IndexNow pings on deploy | Decision | Optional outbound step in `deploy.yml` for faster Bing re-indexing; low urgency for a low-churn lab site | + +## 3. Content + +| Action | Status | Notes | +| ------------------------------------ | -------- | --------------------------------------------------------------------------------------------------------------- | +| Fill in group leader statement | Decision | `statement.text` in `src/data/site.ts` is currently empty; 2–3 sentences give search engines and AI a crisp bio | +| Direct HTTPS link to `curvebook.org` | Ready | Once `HauserGroup/curvebook` enforces HTTPS on `curvebook.org`, update `Software.astro` and `structuredData.ts` | + +## 4. Off-site authority & academic backlinks + +For an academic lab, links from university domains, researcher registries and +papers carry far more authority than generic directories. + +| Action | Status | Notes | +| ----------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| University of Copenhagen (`ku.dk`) links | Account | Link `https://hausergroup.org` from the department group page and from each member's `researchprofiles.ku.dk` profile | +| GitHub Organization & repository metadata | Account / Ready | Point `HauserGroup` org website (`blog`) to `https://hausergroup.org`, add `HauserGroup/.github/profile/README.md`, update `scikit-opls` homepage, and add repo topics (`pharmacoinformatics`, `gpcr`, `pharmacogenomics`, `computational-pharmacology`, `university-of-copenhagen`) | +| ORCID & Google Scholar profiles | Account | Add `https://hausergroup.org` (and individual `/people//` links) to ORCID and Google Scholar profiles | +| Funder & consortium bios | Account | Include `https://hausergroup.org` on EMBO Young Investigator, Lundbeck Foundation, DUA, DFF and ISBUC profile pages | +| Manuscripts & preprints | Ready (ongoing) | Cite `https://hausergroup.org` and `https://hausergroup.org/software/` in Code/Data Availability sections | +| Wikidata entity & `sameAs` | Account | Link Alexander Sebastian Hauser's Wikidata item to ORCID, UCPH and `official website = https://hausergroup.org` | diff --git a/package.json b/package.json index 3294373..2c58259 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dev": "astro dev", "build": "astro build", "preview": "astro preview", + "check:seo": "node scripts/check-seo.mjs", "format": "prettier --write .", "format:check": "prettier --check ." }, diff --git a/public/og-image.png b/public/og-image.png new file mode 100644 index 0000000..3300ff2 Binary files /dev/null and b/public/og-image.png differ diff --git a/scripts/check-seo.mjs b/scripts/check-seo.mjs new file mode 100644 index 0000000..0ad5631 --- /dev/null +++ b/scripts/check-seo.mjs @@ -0,0 +1,230 @@ +import { existsSync, readdirSync, readFileSync, statSync } from "node:fs"; +import { join, relative, sep } from "node:path"; + +const SITE = "https://hausergroup.org"; +const DIST = new URL("../dist", import.meta.url).pathname; + +const errors = []; +const fail = (msg) => errors.push(msg); + +function walk(dir) { + const results = []; + for (const entry of readdirSync(dir)) { + const full = join(dir, entry); + if (statSync(full).isDirectory()) { + results.push(...walk(full)); + } else { + results.push(full); + } + } + return results; +} + +function getAttr(tag, name) { + const re = new RegExp(`\\b${name}\\s*=\\s*"([^"]*)"`, "i"); + return tag.match(re)?.[1]; +} + +function findMeta(html, attrName, attrValue) { + const tags = html.match(/]*>/gi) ?? []; + for (const tag of tags) { + if (getAttr(tag, attrName)?.toLowerCase() === attrValue.toLowerCase()) { + return getAttr(tag, "content"); + } + } + return undefined; +} + +function findCanonicalLinks(html) { + const tags = html.match(/]*>/gi) ?? []; + return tags + .filter((tag) => getAttr(tag, "rel")?.toLowerCase() === "canonical") + .map((tag) => getAttr(tag, "href")); +} + +if (!existsSync(DIST)) { + console.error("dist/ directory not found. Run `npm run build` first."); + process.exit(1); +} + +// 1. Root static assets +const cnamePath = join(DIST, "CNAME"); +if (!existsSync(cnamePath)) { + fail("Missing dist/CNAME"); +} else if (readFileSync(cnamePath, "utf8").trim() !== "hausergroup.org") { + fail(`Unexpected dist/CNAME content: ${readFileSync(cnamePath, "utf8")}`); +} + +const robotsPath = join(DIST, "robots.txt"); +if (!existsSync(robotsPath)) { + fail("Missing dist/robots.txt"); +} else { + const robots = readFileSync(robotsPath, "utf8"); + if (!robots.includes(`Sitemap: ${SITE}/sitemap.xml`)) { + fail( + "dist/robots.txt does not reference https://hausergroup.org/sitemap.xml", + ); + } +} + +const llmsPath = join(DIST, "llms.txt"); +if (!existsSync(llmsPath)) { + fail("Missing dist/llms.txt"); +} else { + const llms = readFileSync(llmsPath, "utf8"); + if (!llms.includes("# Hauser Group") || !llms.includes(`${SITE}/`)) { + fail("dist/llms.txt is missing expected Hauser Group summary or URLs"); + } + if (llms.includes("hausergroup.github.io")) { + fail("dist/llms.txt contains stale hausergroup.github.io reference"); + } +} + +const ogImagePath = join(DIST, "og-image.png"); +if (!existsSync(ogImagePath) || statSync(ogImagePath).size === 0) { + fail("Missing or empty dist/og-image.png"); +} + +if (existsSync(join(DIST, "research", "index.html"))) { + fail("Orphaned dist/research/index.html should not be built"); +} + +// 2. HTML pages & sitemap parity +const allFiles = walk(DIST); +const htmlFiles = allFiles.filter((f) => f.endsWith(".html")); + +const notFoundPath = join(DIST, "404.html"); +if (!existsSync(notFoundPath)) { + fail("Missing dist/404.html"); +} else { + const html404 = readFileSync(notFoundPath, "utf8"); + if (findMeta(html404, "name", "robots") !== "noindex") { + fail('dist/404.html must include '); + } + if (findCanonicalLinks(html404).length > 0) { + fail("dist/404.html must not emit a canonical link"); + } +} + +const indexableFiles = htmlFiles.filter((f) => f !== notFoundPath); +const expectedUrls = new Set(); +const seenTitles = new Map(); +const seenDescriptions = new Map(); + +for (const file of indexableFiles) { + const rel = relative(DIST, file).split(sep).join("/"); + let expectedPath; + if (rel === "index.html") { + expectedPath = "/"; + } else if (rel.endsWith("/index.html")) { + expectedPath = "/" + rel.slice(0, -"/index.html".length) + "/"; + } else { + expectedPath = "/" + rel; + } + const expectedUrl = `${SITE}${expectedPath}`; + expectedUrls.add(expectedUrl); + + const html = readFileSync(file, "utf8"); + + if (html.includes("hausergroup.github.io")) { + fail(`${rel}: contains stale hausergroup.github.io link`); + } + + const title = html.match(/([^<]+)<\/title>/i)?.[1]?.trim(); + if (!title) { + fail(`${rel}: missing <title>`); + } else if (seenTitles.has(title)) { + fail( + `${rel}: duplicate <title> "${title}" (also on ${seenTitles.get(title)})`, + ); + } else { + seenTitles.set(title, rel); + } + + const description = findMeta(html, "name", "description")?.trim(); + if (!description) { + fail(`${rel}: missing <meta name="description">`); + } else { + if (description.length < 50 || description.length > 220) { + fail( + `${rel}: meta description length ${description.length} outside 50–220 chars`, + ); + } + if (seenDescriptions.has(description)) { + fail( + `${rel}: duplicate meta description (also on ${seenDescriptions.get(description)})`, + ); + } else { + seenDescriptions.set(description, rel); + } + } + + const canonicals = findCanonicalLinks(html); + if (canonicals.length !== 1) { + fail(`${rel}: expected 1 canonical link, found ${canonicals.length}`); + } else if (canonicals[0] !== expectedUrl) { + fail(`${rel}: canonical "${canonicals[0]}" !== expected "${expectedUrl}"`); + } + + for (const prop of ["og:title", "og:description", "og:url", "og:image"]) { + if (!findMeta(html, "property", prop)) { + fail(`${rel}: missing meta property="${prop}"`); + } + } + if (!findMeta(html, "name", "twitter:card")) { + fail(`${rel}: missing meta name="twitter:card"`); + } + + const jsonLdMatches = [ + ...html.matchAll( + /<script\b[^>]*type="application\/ld\+json"[^>]*>([\s\S]*?)<\/script>/gi, + ), + ]; + if (jsonLdMatches.length === 0) { + fail(`${rel}: missing JSON-LD structured data`); + } + for (const match of jsonLdMatches) { + try { + const parsed = JSON.parse(match[1]); + if (parsed["@context"] !== "https://schema.org") { + fail(`${rel}: JSON-LD missing "@context": "https://schema.org"`); + } + } catch (err) { + fail(`${rel}: invalid JSON-LD (${err.message})`); + } + } +} + +// 3. Validate sitemap.xml +const sitemapPath = join(DIST, "sitemap.xml"); +if (!existsSync(sitemapPath)) { + fail("Missing dist/sitemap.xml"); +} else { + const sitemap = readFileSync(sitemapPath, "utf8"); + const locs = [...sitemap.matchAll(/<loc>([^<]+)<\/loc>/g)].map((m) => m[1]); + const locSet = new Set(locs); + if (locs.length !== locSet.size) { + fail("dist/sitemap.xml contains duplicate <loc> entries"); + } + for (const url of expectedUrls) { + if (!locSet.has(url)) { + fail(`dist/sitemap.xml is missing built page: ${url}`); + } + } + for (const url of locSet) { + if (!expectedUrls.has(url)) { + fail(`dist/sitemap.xml lists non-existent page: ${url}`); + } + } +} + +if (errors.length > 0) { + console.error( + "SEO check failed:\n" + errors.map((e) => ` - ${e}`).join("\n"), + ); + process.exit(1); +} + +console.log( + `SEO check passed: ${indexableFiles.length} indexable pages, sitemap.xml, robots.txt, llms.txt, CNAME, og-image.png.`, +); diff --git a/src/components/CategoryPage.astro b/src/components/CategoryPage.astro index b85e154..7d2d6f8 100644 --- a/src/components/CategoryPage.astro +++ b/src/components/CategoryPage.astro @@ -1,13 +1,27 @@ --- import Base from "../layouts/Base.astro"; +import { breadcrumbJsonLd, type JsonLd } from "../data/structuredData"; + interface Props { title: string; + description: string; tone?: string; + jsonLd?: JsonLd | JsonLd[]; } -const { title, tone = "b" } = Astro.props; +const { title, description, tone = "b", jsonLd } = Astro.props; +const siteOrigin = Astro.site ?? new URL("https://hausergroup.org"); +const breadcrumb = breadcrumbJsonLd( + [{ name: title, path: Astro.url.pathname }], + siteOrigin, +); +const extraJsonLd = jsonLd ? (Array.isArray(jsonLd) ? jsonLd : [jsonLd]) : []; --- -<Base title={title + " · Hauser Group"}> +<Base + title={title + " · Hauser Group"} + description={description} + jsonLd={[breadcrumb, ...extraJsonLd]} +> <div class:list={["wrap", "directory-page", tone]}> <header class="directory-heading"> <h1>{title}</h1> diff --git a/src/components/MemberPortrait.astro b/src/components/MemberPortrait.astro index aa9d5f6..fc59e73 100644 --- a/src/components/MemberPortrait.astro +++ b/src/components/MemberPortrait.astro @@ -2,15 +2,16 @@ interface Props { src?: string; initials: string; + alt?: string; eager?: boolean; } -const { src, initials, eager = false } = Astro.props; +const { src, initials, alt = "", eager = false } = Astro.props; --- {src ? ( <img src={src} - alt="" + alt={alt} width="640" height="640" loading={eager ? "eager" : "lazy"} diff --git a/src/data/structuredData.ts b/src/data/structuredData.ts new file mode 100644 index 0000000..916a401 --- /dev/null +++ b/src/data/structuredData.ts @@ -0,0 +1,201 @@ +import { groupEmail } from "./contact"; +import { hauserOrcid, hauserScholar, profiles } from "./profiles"; +import type { PublicationSection } from "./publications"; +import { GROUP_PAGE } from "./site"; + +export type JsonLd = Record<string, unknown>; + +export const SITE_NAME = "Hauser Group"; +export const DEFAULT_DESCRIPTION = + "The Hauser Group at the University of Copenhagen studies how human genetic variation changes the way G protein-coupled receptors (GPCRs) respond to drugs."; +export const DEFAULT_OG_IMAGE = "/og-image.png"; +export const DEFAULT_OG_IMAGE_ALT = + "Hauser Group · Pharmacoinformatics, Department of Drug Design and Pharmacology, University of Copenhagen"; + +export function organizationJsonLd(site: URL): JsonLd { + return { + "@context": "https://schema.org", + "@type": "ResearchOrganization", + "@id": new URL("/#organization", site).href, + name: SITE_NAME, + alternateName: ["Hauser Lab", "Hauser Group · Pharmacoinformatics"], + url: new URL("/", site).href, + logo: new URL("/favicon.svg", site).href, + image: new URL(DEFAULT_OG_IMAGE, site).href, + email: groupEmail, + description: DEFAULT_DESCRIPTION, + parentOrganization: { + "@type": "Organization", + name: "Department of Drug Design and Pharmacology", + url: "https://drug.ku.dk/", + parentOrganization: { + "@type": "CollegeOrUniversity", + name: "University of Copenhagen", + url: "https://www.ku.dk/", + sameAs: ["https://ror.org/035b05819"], + }, + }, + address: { + "@type": "PostalAddress", + streetAddress: "Universitetsparken 2", + postalCode: "2100", + addressLocality: "Copenhagen", + addressCountry: "DK", + }, + founder: { + "@type": "Person", + "@id": new URL("/people/alexander-hauser/#person", site).href, + name: "Alexander Sebastian Hauser", + }, + sameAs: [ + GROUP_PAGE, + "https://github.com/HauserGroup", + hauserScholar, + hauserOrcid, + ], + }; +} + +export function websiteJsonLd(site: URL): JsonLd { + return { + "@context": "https://schema.org", + "@type": "WebSite", + "@id": new URL("/#website", site).href, + name: SITE_NAME, + url: new URL("/", site).href, + publisher: { "@id": new URL("/#organization", site).href }, + }; +} + +export function breadcrumbJsonLd( + items: { name: string; path: string }[], + site: URL, +): JsonLd { + const full = + items[0]?.path === "/" ? items : [{ name: "Home", path: "/" }, ...items]; + return { + "@context": "https://schema.org", + "@type": "BreadcrumbList", + itemListElement: full.map((item, index) => ({ + "@type": "ListItem", + position: index + 1, + name: item.name, + item: new URL(item.path, site).href, + })), + }; +} + +export function personJsonLd( + person: (typeof profiles)[number], + site: URL, +): JsonLd { + const sameAs: string[] = []; + if (person.universityId) { + sameAs.push( + `https://researchprofiles.ku.dk/en/persons/${person.universityId}/`, + ); + } + if (person.orcid) sameAs.push(person.orcid); + if (person.scholar) sameAs.push(person.scholar); + if (person.linkedin) { + sameAs.push(`https://www.linkedin.com/in/${person.linkedin}/`); + } + if (person.github) sameAs.push(`https://github.com/${person.github}`); + + const orgRef = { + "@type": "ResearchOrganization", + "@id": new URL("/#organization", site).href, + name: "Hauser Group, University of Copenhagen", + }; + + return { + "@context": "https://schema.org", + "@type": "Person", + "@id": new URL(`/people/${person.slug}/#person`, site).href, + name: person.name, + familyName: person.familyName, + jobTitle: person.title, + url: new URL(`/people/${person.slug}/`, site).href, + ...(person.portrait + ? { image: new URL(person.portrait, site).href } + : undefined), + ...(person.alumni + ? { alumniOf: orgRef } + : { worksFor: orgRef, affiliation: orgRef }), + ...(sameAs.length > 0 ? { sameAs } : undefined), + }; +} + +export function softwareJsonLd(site: URL): JsonLd { + const author = { "@id": new URL("/#organization", site).href }; + return { + "@context": "https://schema.org", + "@type": "ItemList", + name: "Hauser Group Software", + url: new URL("/software/", site).href, + itemListElement: [ + { + "@type": "ListItem", + position: 1, + item: { + "@type": "SoftwareApplication", + name: "CurveBook", + url: "https://hausergroup.org/curvebook/", + applicationCategory: "ScientificApplication", + description: + "Open-source biostatistics, nonlinear curve fitting and scientific graphing tool written in Rust.", + programmingLanguage: "Rust", + author, + }, + }, + { + "@type": "ListItem", + position: 2, + item: { + "@type": "SoftwareApplication", + name: "scikit-opls", + url: "https://hausergroup.org/scikit-opls/", + applicationCategory: "ScientificApplication", + softwareVersion: "0.2.0", + description: + "Open-source Python implementation of OPLS, OPLS-DA and O2PLS with a scikit-learn interface, VIP scores, S-plots and permutation tests.", + programmingLanguage: "Python", + author, + }, + }, + ], + }; +} + +export function publicationsJsonLd( + sections: PublicationSection[], + site: URL, +): JsonLd { + const papers = sections.flatMap((section) => section.papers); + return { + "@context": "https://schema.org", + "@type": "CollectionPage", + name: "Publications · Hauser Group", + url: new URL("/publications/", site).href, + isPartOf: { "@id": new URL("/#website", site).href }, + mainEntity: { + "@type": "ItemList", + numberOfItems: papers.length, + itemListElement: papers.map((paper, index) => ({ + "@type": "ListItem", + position: index + 1, + item: { + "@type": "ScholarlyArticle", + headline: paper.title, + datePublished: paper.publishedOn ?? paper.year, + url: `https://doi.org/${paper.doi}`, + sameAs: `https://doi.org/${paper.doi}`, + isPartOf: { + "@type": "Periodical", + name: paper.journal, + }, + }, + })), + }, + }; +} diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 842bd3b..8ef6634 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -2,10 +2,22 @@ import "../styles/site.css"; import Logo from "../components/Logo.astro"; import { GROUP_PAGE } from "../data/site"; +import { + DEFAULT_DESCRIPTION, + DEFAULT_OG_IMAGE, + DEFAULT_OG_IMAGE_ALT, + SITE_NAME, + type JsonLd, +} from "../data/structuredData"; interface Props { title?: string; description?: string; + noindex?: boolean; + ogType?: "website" | "profile"; + ogImage?: string; + ogImageAlt?: string; + jsonLd?: JsonLd | JsonLd[]; } // Keep the header short: the homepage tells the story, the rest is in the footer. @@ -27,8 +39,21 @@ const active = (href: string) => Astro.url.pathname.startsWith(href) ? "page" : undefined; const { title = "Hauser Group · Pharmacoinformatics", - description = "The Hauser Group studies how human genetic variation changes the way G protein-coupled receptors respond to drugs. Department of Drug Design and Pharmacology, University of Copenhagen.", + description = DEFAULT_DESCRIPTION, + noindex = false, + ogType = "website", + ogImage, + ogImageAlt = DEFAULT_OG_IMAGE_ALT, + jsonLd, } = Astro.props; + +const siteOrigin = Astro.site ?? new URL("https://hausergroup.org"); +const canonicalUrl = noindex + ? undefined + : new URL(Astro.url.pathname, siteOrigin).href; +const resolvedOgImage = new URL(ogImage ?? DEFAULT_OG_IMAGE, siteOrigin).href; +const twitterCard = ogImage ? "summary" : "summary_large_image"; +const jsonLdBlocks = jsonLd ? (Array.isArray(jsonLd) ? jsonLd : [jsonLd]) : []; --- <!doctype html> @@ -41,6 +66,19 @@ const { /> <title>{title} + {noindex && } + {canonicalUrl && } + + + + + {canonicalUrl && } + + + + + + @@ -48,6 +86,13 @@ const { rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap" /> + {jsonLdBlocks.map((block) => ( +