Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add HowTo structured data to /how-to-screen-record

Richie McIlroy71d010c15e09
diff --git a/apps/web/__tests__/unit/howto-schema.test.ts b/apps/web/__tests__/unit/howto-schema.test.ts
new file mode 100644
index 000000000..2ee3de6a1
--- /dev/null
+++ b/apps/web/__tests__/unit/howto-schema.test.ts
@@ -0,0 +1,130 @@
+import { describe, expect, it } from "vitest";
+import { createHowToSchema } from "@/utils/web-schema";
+
+describe("createHowToSchema", () => {
+ it("produces valid HowTo schema structure", () => {
+ const schema = createHowToSchema({
+ name: "How to Screen Record",
+ description: "A guide to screen recording.",
+ steps: [{ name: "Step 1", text: "Do the first thing." }],
+ });
+
+ expect(schema["@context"]).toBe("https://schema.org");
+ expect(schema["@type"]).toBe("HowTo");
+ expect(schema.name).toBe("How to Screen Record");
+ expect(schema.description).toBe("A guide to screen recording.");
+ });
+
+ it("maps each step to a HowToStep with correct position", () => {
+ const steps = [
+ { name: "Download", text: "Download the app." },
+ { name: "Install", text: "Install the app." },
+ { name: "Record", text: "Click record." },
+ ];
+ const schema = createHowToSchema({
+ name: "How to Record",
+ description: "A guide.",
+ steps,
+ });
+
+ expect(schema.step).toHaveLength(3);
+ expect(schema.step[0]).toEqual({
+ "@type": "HowToStep",
+ position: 1,
+ name: "Download",
+ text: "Download the app.",
+ });
+ expect(schema.step[1].position).toBe(2);
+ expect(schema.step[2].position).toBe(3);
+ });
+
+ it("uses default totalTime of PT2M when not provided", () => {
+ const schema = createHowToSchema({
+ name: "Test",
+ description: "Test.",
+ steps: [],
+ });
+
+ expect(schema.totalTime).toBe("PT2M");
+ });
+
+ it("uses provided totalTime when specified", () => {
+ const schema = createHowToSchema({
+ name: "Test",
+ description: "Test.",
+ totalTime: "PT5M",
+ steps: [],
+ });
+
+ expect(schema.totalTime).toBe("PT5M");
+ });
+
+ it("handles empty steps array", () => {
+ const schema = createHowToSchema({
+ name: "Test",
+ description: "Test.",
+ steps: [],
+ });
+
+ expect(schema.step).toHaveLength(0);
+ expect(Array.isArray(schema.step)).toBe(true);
+ });
+
+ it("produces JSON-serializable output", () => {
+ const schema = createHowToSchema({
+ name: "How to Screen Record on Mac",
+ description: "Learn how to screen record.",
+ totalTime: "PT2M",
+ steps: [
+ {
+ name: "Download and install Cap",
+ text: "Download Cap for free from cap.so/download.",
+ },
+ {
+ name: "Start recording",
+ text: "Click the record button.",
+ },
+ ],
+ });
+
+ expect(() => JSON.stringify(schema)).not.toThrow();
+
+ const parsed = JSON.parse(JSON.stringify(schema));
+ expect(parsed["@type"]).toBe("HowTo");
+ expect(parsed["@context"]).toBe("https://schema.org");
+ expect(parsed.step).toHaveLength(2);
+ });
+
+ it("applies schema to how-to-screen-record page steps", () => {
+ const howToSteps = [
+ {
+ name: "Download and install Cap",
+ text: "Download Cap for free from cap.so/download for Mac or Windows.",
+ },
+ {
+ name: "Choose your recording settings",
+ text: "Open Cap and select your recording source.",
+ },
+ {
+ name: "Start recording your screen",
+ text: "Click the record button to begin capturing your screen.",
+ },
+ {
+ name: "Share or export your recording",
+ text: "Stop the recording when finished.",
+ },
+ ];
+ const schema = createHowToSchema({
+ name: "How to Screen Record on Mac, Windows & Chrome",
+ description:
+ "Learn how to screen record with audio on Mac, Windows, or in your browser using Cap.",
+ totalTime: "PT2M",
+ steps: howToSteps,
+ });
+
+ expect(schema["@type"]).toBe("HowTo");
+ expect(schema.step).toHaveLength(4);
+ expect(schema.step[0].name).toBe("Download and install Cap");
+ expect(schema.step[3].position).toBe(4);
+ });
+});
diff --git a/apps/web/app/(site)/(seo)/how-to-screen-record/page.tsx b/apps/web/app/(site)/(seo)/how-to-screen-record/page.tsx
index 314da5257..49a095f34 100644
--- a/apps/web/app/(site)/(seo)/how-to-screen-record/page.tsx
+++ b/apps/web/app/(site)/(seo)/how-to-screen-record/page.tsx
@@ -1,5 +1,10 @@
import type { Metadata } from "next";
-import { HowToScreenRecordPage } from "@/components/pages/seo/HowToScreenRecordPage";
+import Script from "next/script";
+import {
+ HowToScreenRecordPage,
+ howToScreenRecordContent,
+} from "@/components/pages/seo/HowToScreenRecordPage";
+import { createFAQSchema, createHowToSchema } from "@/utils/web-schema";
export const metadata: Metadata = {
title: "How to Screen Record on Mac, Windows & Chrome (2026 Guide) | Cap",
@@ -34,6 +39,53 @@ export const metadata: Metadata = {
},
};
+const howToSteps = [
+ {
+ name: "Download and install Cap",
+ text: "Download Cap for free from cap.so/download for Mac or Windows, or use Instant Mode in your browser for quick recordings without any installation.",
+ },
+ {
+ name: "Choose your recording settings",
+ text: "Open Cap and select your recording source. Choose between full screen, specific window, or custom region capture. Toggle microphone and system audio on or off based on your needs.",
+ },
+ {
+ name: "Start recording your screen",
+ text: "Click the record button to begin capturing your screen. Cap records in high definition with minimal system impact so you can present, demo, or teach without lag.",
+ },
+ {
+ name: "Share or export your recording",
+ text: "Stop the recording when finished. Cap generates an instant shareable link, or you can export the video locally in your preferred format. Share your recording with anyone in seconds.",
+ },
+];
+
export default function Page() {
- return <HowToScreenRecordPage />;
+ return (
+ <>
+ <Script
+ id="faq-structured-data"
+ type="application/ld+json"
+ dangerouslySetInnerHTML={{
+ __html: JSON.stringify(
+ createFAQSchema(howToScreenRecordContent.faqs),
+ ),
+ }}
+ />
+ <Script
+ id="howto-structured-data"
+ type="application/ld+json"
+ dangerouslySetInnerHTML={{
+ __html: JSON.stringify(
+ createHowToSchema({
+ name: "How to Screen Record on Mac, Windows & Chrome",
+ description:
+ "Learn how to screen record with audio on Mac, Windows, or in your browser using Cap, the free open-source screen recorder.",
+ totalTime: "PT2M",
+ steps: howToSteps,
+ }),
+ ),
+ }}
+ />
+ <HowToScreenRecordPage />
+ </>
+ );
}
diff --git a/apps/web/components/pages/seo/HowToScreenRecordPage.tsx b/apps/web/components/pages/seo/HowToScreenRecordPage.tsx
index 02fcea676..1bc3e937e 100644
--- a/apps/web/components/pages/seo/HowToScreenRecordPage.tsx
+++ b/apps/web/components/pages/seo/HowToScreenRecordPage.tsx
@@ -1,6 +1,5 @@
"use client";
-import Script from "next/script";
import { SeoPageTemplate } from "../../seo/SeoPageTemplate";
import type { SeoPageContent } from "../../seo/types";
@@ -227,76 +226,6 @@ export const howToScreenRecordContent: SeoPageContent = {
},
};
-const createFaqStructuredData = () => {
- const faqStructuredData = {
- "@context": "https://schema.org",
- "@type": "FAQPage",
- mainEntity: howToScreenRecordContent.faqs.map((faq) => ({
- "@type": "Question",
- name: faq.question,
- acceptedAnswer: {
- "@type": "Answer",
- text: faq.answer.replace(/<\/?[^>]+(>|$)/g, ""),
- },
- })),
- };
-
- return JSON.stringify(faqStructuredData);
-};
-
-const createHowToStructuredData = () => {
- const howToStructuredData = {
- "@context": "https://schema.org",
- "@type": "HowTo",
- name: "How to Screen Record on Mac, Windows & Chrome",
- description:
- "Learn how to screen record with audio on Mac, Windows, or in your browser using Cap, the free open-source screen recorder.",
- totalTime: "PT2M",
- step: [
- {
- "@type": "HowToStep",
- position: 1,
- name: "Download and install Cap",
- text: "Download Cap for free from cap.so/download for Mac or Windows, or use Instant Mode in your browser for quick recordings without any installation.",
- },
- {
- "@type": "HowToStep",
- position: 2,
- name: "Choose your recording settings",
- text: "Open Cap and select your recording source. Choose between full screen, specific window, or custom region capture. Toggle microphone and system audio on or off based on your needs.",
- },
- {
- "@type": "HowToStep",
- position: 3,
- name: "Start recording your screen",
- text: "Click the record button to begin capturing your screen. Cap records in high definition with minimal system impact so you can present, demo, or teach without lag.",
- },
- {
- "@type": "HowToStep",
- position: 4,
- name: "Share or export your recording",
- text: "Stop the recording when finished. Cap generates an instant shareable link, or you can export the video locally in your preferred format. Share your recording with anyone in seconds.",
- },
- ],
- };
-
- return JSON.stringify(howToStructuredData);
-};
-
export const HowToScreenRecordPage = () => {
- return (
- <>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{ __html: createFaqStructuredData() }}
- />
- <Script
- id="howto-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{ __html: createHowToStructuredData() }}
- />
- <SeoPageTemplate content={howToScreenRecordContent} />
- </>
- );
+ return <SeoPageTemplate content={howToScreenRecordContent} />;
};
diff --git a/apps/web/utils/web-schema.ts b/apps/web/utils/web-schema.ts
index 264570a4f..2e71724c4 100644
--- a/apps/web/utils/web-schema.ts
+++ b/apps/web/utils/web-schema.ts
@@ -252,6 +252,25 @@ export const createComparisonTableSchema = () => ({
},
});
+export const createHowToSchema = (params: {
+ name: string;
+ description: string;
+ totalTime?: string;
+ steps: Array<{ name: string; text: string }>;
+}) => ({
+ "@context": "https://schema.org",
+ "@type": "HowTo",
+ name: params.name,
+ description: params.description,
+ totalTime: params.totalTime || "PT2M",
+ step: params.steps.map((step, index) => ({
+ "@type": "HowToStep",
+ position: index + 1,
+ name: step.name,
+ text: step.text,
+ })),
+});
+
export const createLocalBusinessSchema = () => ({
"@context": "https://schema.org",
"@type": "LocalBusiness",