{"id":16229773,"url":"https://github.com/indaco/teseo","last_synced_at":"2025-03-19T14:30:21.730Z","repository":{"id":255655270,"uuid":"853336273","full_name":"indaco/teseo","owner":"indaco","description":"Go templ components for SEO","archived":false,"fork":false,"pushed_at":"2024-10-07T14:09:13.000Z","size":132,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T07:44:54.126Z","etag":null,"topics":["components","go","golang","seo","templ"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/indaco.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-06T13:04:56.000Z","updated_at":"2025-02-17T13:20:45.000Z","dependencies_parsed_at":"2024-10-27T20:36:33.926Z","dependency_job_id":"b0e392c2-655e-4380-b62a-5c3780b90c64","html_url":"https://github.com/indaco/teseo","commit_stats":null,"previous_names":["indaco/teseo"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indaco%2Fteseo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indaco%2Fteseo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indaco%2Fteseo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indaco%2Fteseo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indaco","download_url":"https://codeload.github.com/indaco/teseo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244444370,"owners_count":20453710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["components","go","golang","seo","templ"],"created_at":"2024-10-10T12:59:12.991Z","updated_at":"2025-03-19T14:30:21.438Z","avatar_url":"https://github.com/indaco.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\" style=\"font-size: 2.5rem;\"\u003eteseo\u003c/h1\u003e\n\u003ch2 align=\"center\"\u003eGo templ components for SEO\u003c/h2\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/indaco/teseo/blob/main/LICENSE\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-mit-blue?style=flat-square\u0026logo=none\" alt=\"license\" /\u003e\n    \u003c/a\u003e\n     \u0026nbsp;\n     \u003ca href=\"https://goreportcard.com/report/github.com/indaco/teseo\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://goreportcard.com/badge/indaco/teseo\" alt=\"go report card\" /\u003e\n    \u003c/a\u003e\n    \u0026nbsp;\n    \u003ca href=\"https://pkg.go.dev/github.com/indaco/teseo/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://pkg.go.dev/badge/github.com/indaco/teseo/.svg\" alt=\"go reference\" /\u003e\n    \u003c/a\u003e\n    \u0026nbsp;\n    \u003ca href=\"https://www.jetify.com/devbox/docs/contributor-quickstart/\"\u003e\n      \u003cimg\n          src=\"https://www.jetify.com/img/devbox/shield_moon.svg\"\n          alt=\"Built with Devbox\"\n      /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n`teseo` provides a comprehensive list of SEO-related data types (go structs) that adhere to **Schema.org** and **OpenGraph** specifications, with methods to easily generate [templ](https://github.com/a-h/templ) components or standard `template/html` output from them.\n\nWhether you are looking to implement _Schema.org JSON-LD_, _OpenGraph_, or _Twitter Cards_, `teseo` helps you generate SEO-friendly meta information effortlessly.\n\n## Features\n\n- A comprehensive list of useful **Schema.org JSON-LD** types.\n- A comprehensive list of useful **OpenGraph** meta tags.\n- Support for **Twitter Cards** meta tags.\n- Easy-to-use methods to generate JSON-LD and meta tags.\n- Render data types as **templ components** or using **template/html**.\n\n## Supported Data Types\n\n### Schema.org JSON-LD Entities\n\n- Article\n- BreadcrumbList\n- Event\n- FAQPage\n- LocalBusiness\n- Organization\n- Person\n- Product\n- SiteNavigationElement\n- WebPage\n- WebSite\n\n### OpenGraph Data Types\n\n- Article\n- Audio\n- Book\n- Business\n- Event\n- MusicAlbum\n- MusicPlaylist\n- MusicSong\n- MusicRadioStation\n- Place\n- Profile\n- Product\n- ProductGroup\n- Restaurant\n- Video\n- VideoEpisode\n- VideoMovie\n- Website\n\n### Twitter Cards\n\n- Summary Card\n- Summary with Large Image\n- App Card\n- Player Card\n\n## Installation\n\nAdd this package to your project:\n\n```bash\ngo get github.com/indaco/teseo@latest\n```\n\n## Usage\n\n### Schema.org JSON-LD\n\nFor **Schema.org JSON-LD**, each entity provides `ToJsonLd` and `ToGoHTMLJsonLd` methods. You can render the structured data as a templ component or as an HTML string, suitable for Go's `template/html`. Entities can be created using **pure structs** or **factory methods**.\n\n#### Example: WebPage\n\n```templ\npackage pages\n\nimport \"github.com/indaco/teseo/schemaorg\"\n\ntempl HomePage() {\n {{\n    webpage := \u0026schemaorg.WebPage{\n        URL:         \"https://www.example.com\",\n        Name:        \"Example WebPage\",\n        Headline:    \"Welcome to Example WebPage\",\n        Description: \"This is an example webpage.\",\n        About:       \"Something related to the home page\",\n        Keywords:    \"example, webpage, demo\",\n        InLanguage:  \"en\",\n    }\n }}\n \u003c!DOCTYPE html\u003e\n \u003chtml lang=\"en\"\u003e\n   \u003chead\u003e\n      \u003cmeta charset=\"UTF-8\"/\u003e\n      \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/\u003e\n      \u003ctitle\u003eteseo - homepage\u003c/title\u003e\n      \u003c!-- render JSON-LD here --\u003e\n      @webpage.ToJsonLd()\n    \u003c/head\u003e\n    \u003cbody\u003e\n       \u003c!-- your content --\u003e\n    \u003c/body\u003e\n \u003c/html\u003e\n}\n```\n\nThe expected output:\n\n```html\n\u003cscript type=\"application/ld+json\"\u003e\n{\n  \"@context\": \"https://schema.org\",\n  \"@type\": \"WebPage\",\n  \"url\": \"https://www.example.com\",\n  \"name\": \"Example WebPage\",\n  \"headline\": \"Welcome to Example WebPage\",\n  \"description\": \"This is an example webpage\",\n  \"about\": \"Something related to the home page\",\n  \"keywords\": \"example, webpage, demo\",\n  \"inLanguage\": \"en\"\n}\n\u003c/script\u003e\n```\n\n#### Example: BreadcrumbList using NewBreadcrumbListFromUrl\n\n`teseo` also provides utility methods such as `NewBreadcrumbListFromUrl`, which helps you automatically generate a breadcrumb list based on the full page URL. This method is invaluable during development, as it helps quickly generate and structure breadcrumb navigation for dynamic or complex URLs, making debugging faster and more efficient.\n\n```templ\npackage main\n\nimport (\n    \"github.com/indaco/teseo/schemaorg\"\n    \"github.com/indaco/teseo\"\n    \"net/http\"\n)\n\nfunc HandleAbout(w http.ResponseWriter, r *http.Request) {\n    pageURL := teseo.GetFullURL(r) // Helper function to get the full URL from the request\n    breadcrumbList, err := schemaorg.NewBreadcrumbListFromUrl(pageURL)\n    if err != nil {\n        fmt.Println(\"Error generating breadcrumb list:\", err)\n        return\n    }\n\n    err = pages.AboutPage(breadcrumbList).Render(r.Context(), w)\n    if err != nil {\n        return\n    }\n}\n\ntempl AboutPage(breadcrumbList *schemaorg.BreadcrumbList) {\n    \u003c!DOCTYPE html\u003e\n    \u003chtml lang=\"en\"\u003e\n        \u003chead\u003e\n            \u003cmeta charset=\"UTF-8\"/\u003e\n            \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/\u003e\n            \u003ctitle\u003eteseo - about\u003c/title\u003e\n            \u003c!-- render JSON-LD here --\u003e\n            @breadcrumbList.ToJsonLd()\n        \u003c/head\u003e\n        \u003cbody\u003e\n            \u003c!-- your content --\u003e\n        \u003c/body\u003e\n    \u003c/html\u003e\n}\n```\n\nThe expected output for a URL like `https://www.example.com/about`:\n\n```html\n\u003cscript type=\"application/ld+json\"\u003e\n{\n  \"@context\": \"https://schema.org\",\n  \"@type\": \"BreadcrumbList\",\n  \"itemListElement\": [\n    {\n      \"@type\": \"ListItem\",\n      \"position\": 1,\n      \"name\": \"Home\",\n      \"item\": \"https://www.example.com\"\n    },\n    {\n      \"@type\": \"ListItem\",\n      \"position\": 2,\n      \"name\": \"About\",\n      \"item\": \"https://www.example.com/about\"\n    }\n  ]\n}\n\u003c/script\u003e\n```\n\n#### SiteNavigationElement: JSON-LD and Sitemap Generation\n\nThe **SiteNavigationElement** represents a Schema.org object that can be used to structure site navigation data. This entity supports both JSON-LD generation and the creation of a sitemap XML file.\n\n**Factory method usage:**\n\n```go\npackage pages\n\nimport \"github.com/indaco/teseo/schemaorg\"\n\ntempl HomePage() {\n {{\n    sne := schemaorg.NewSiteNavigationElementWithItemList(\n      \"Main Navigation\",\n      \"https://www.example.com\",\n      []schemaorg.ItemListElement{\n        {Name: \"Home\", URL: \"https://www.example.com\", Position: 1},\n        {Name: \"About\", URL: \"https://www.example.com/about\", Position: 2},\n      },\n    )\n }}\n \u003c!DOCTYPE html\u003e\n \u003chtml lang=\"en\"\u003e\n   \u003chead\u003e\n      \u003cmeta charset=\"UTF-8\"/\u003e\n      \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/\u003e\n      \u003ctitle\u003eteseo - homepage\u003c/title\u003e\n      \u003c!-- render JSON-LD here --\u003e\n      @sne.ToJsonLd()\n    \u003c/head\u003e\n    \u003cbody\u003e\n       \u003c!-- your content --\u003e\n    \u003c/body\u003e\n \u003c/html\u003e\n}\n```\n\nThe expected output:\n\n```html\n\u003cscript type=\"application/ld+json\"\u003e\n{\n  \"@context\": \"https://schema.org\",\n  \"@type\": \"SiteNavigationElement\",\n  \"name\": \"Main Navigation\",\n  \"url\": \"https://www.example.com\",\n  \"position\": 1,\n  \"itemListElement\": [\n    {\"@type\": \"ListItem\", \"position\": 1, \"name\": \"Home\", \"url\": \"https://www.example.com\"},\n    {\"@type\": \"ListItem\", \"position\": 2, \"name\": \"About\", \"url\": \"https://www.example.com/about\"}\n  ]\n}\n\u003c/script\u003e\n```\n\n**Sitemap XML Generation:**\n\n```go\npackage handlers\n\nimport (\n  \"log\"\n  \"net/http\"\n\n  \"github.com/indaco/teseo/schemaorg\"\n)\n\nfunc HandleHome(w http.ResponseWriter, r *http.Request) {\n  sne := schemaorg.NewSiteNavigationElementWithItemList(\n    \"Main Navigation\",\n    \"https://www.example.com\",\n    []schemaorg.ItemListElement{\n      {Name: \"Home\", URL: \"https://www.example.com\", Position: 1},\n      {Name: \"About\", URL: \"https://www.example.com/about\", Position: 2},\n    },\n  )\n\n\n  err := sne.ToSitemapFile(\"./_demos/statics/sitemap.xml\")\n  if err != nil {\n    log.Fatalf(\"Failed to generate sitemap: %v\", err)\n  }\n\n  err = pages.HomePage(sne).Render(r.Context(), w)\n  if err != nil {\n    return\n  }\n}\n```\n\nSimilarly, the `FromSitemapFile` method allows you to parse a sitemap XML file and populate the `SiteNavigationElement` struct. This can speed up the debugging process and is particularly useful when working with dynamically generated sitemaps.\n\n### OpenGraph Meta Tags\n\nFor **OpenGraph**, entities come with `ToMetaTags` and `ToGoHTMLMetaTags` methods that generates the necessary meta tags for OpenGraph data. Similar to Schema.org, you can either create the entity via a **pure struct** or a **factory method**. Here’s an example for generating meta tags for an _Article_:\n\n```templ\npackage pages\n\nimport \"github.com/indaco/teseo/opengraph\"\n\ntempl FirstArticle() {\n {{\n    article := \u0026opengraph.Article{\n        Title:       \"Example Article\",\n        URL:         \"https://www.example.com/article/example-article\",\n        Description: \"This is an example article description.\",\n        Image:       \"https://www.example.com/images/article.jpg\",\n    }\n }}\n \u003c!DOCTYPE html\u003e\n \u003chtml lang=\"en\"\u003e\n   \u003chead\u003e\n      \u003cmeta charset=\"UTF-8\"/\u003e\n      \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/\u003e\n      \u003ctitle\u003eteseo - first article\u003c/title\u003e\n      \u003c!-- render opengraph metadata here --\u003e\n      @article.ToMetaTags()\n    \u003c/head\u003e\n    \u003cbody\u003e\n       \u003c!-- your content --\u003e\n    \u003c/body\u003e\n \u003c/html\u003e\n}\n```\n\nThe expected output:\n\n```html\n\u003cmeta property=\"og:type\" content=\"article\"/\u003e\n\u003cmeta property=\"og:title\" content=\"Example Article\"/\u003e\n\u003cmeta property=\"og:url\" content=\"https://www.example.com/article/example-article\"/\u003e\n\u003cmeta property=\"og:description\" content=\"This is an example article description.\"/\u003e\n\u003cmeta property=\"og:image\" content=\"https://www.example.com/images/article.jpg\"/\u003e\n```\n\n### Twitter Cards\n\nFor **Twitter Cards**, you can also use either the **pure struct** or **factory methods** to generate Twitter Card meta tags via the `ToMetaTags` and `ToGoHTMLMetaTags` methods. Here’s how to generate a _Twitter Summary Card_.\n\n```templ\npackage pages\n\nimport \"github.com/indaco/teseo/twittercard\"\n\ntempl AboutMe() {\n {{\n    twCard := \u0026twittercard.TwitterCard{\n        Card:        twittercard.CardSummary,\n        Title:       \"Example Summary\",\n        Description: \"This is an example summary card.\",\n        Image:       \"https://www.example.com/summary.jpg\",\n        Site:        \"@example_site\",\n    }\n }}\n \u003c!DOCTYPE html\u003e\n \u003chtml lang=\"en\"\u003e\n   \u003chead\u003e\n      \u003cmeta charset=\"UTF-8\"/\u003e\n      \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/\u003e\n      \u003ctitle\u003eteseo - first article\u003c/title\u003e\n      \u003c!-- render twittercard metadata here --\u003e\n      @twCard.ToMetaTags()\n    \u003c/head\u003e\n    \u003cbody\u003e\n      \u003c!-- your content --\u003e\n    \u003c/body\u003e\n \u003c/html\u003e\n}\n```\n\nThe expected output:\n\n```html\n\u003cmeta name=\"twitter:card\" content=\"summary\"/\u003e\n\u003cmeta name=\"twitter:title\" content=\"Example Summary\"/\u003e\n\u003cmeta name=\"twitter:description\" content=\"This is an example summary card.\"/\u003e\n\u003cmeta name=\"twitter:image\" content=\"https://www.example.com/summary.jpg\"/\u003e\n\u003cmeta name=\"twitter:site\" content=\"@example_site\"/\u003e\n```\n\nThis works for all supported Twitter Cards (e.g., App Card, Player Card, etc.).\n\n## Demo\n\nA sample website is available in the **_demos** folder, which demonstrates how to integrate teseo for generating structured data and metadata. This demo serves as a reference for implementing Schema.org JSON-LD, OpenGraph, and Twitter Cards in your own web applications.\n\nFeel free to explore the demo to see real-world usage of the library and how easily you can add SEO-friendly metadata to your Go web projects.\n\n### Run the demo\n\n```bash\n# Taskfile\ntask live # http://localhost:7332\n# Makefile\nmake live # http://localhost:7332\n```\n\n## Contributing\n\nContributions are welcome! Feel free to open an issue or submit a pull request.\n\n### Development Environment Setup\n\nTo set up a development environment for this repository, you can use [devbox](https://www.jetify.com/devbox) along with the provided `devbox.json` configuration file.\n\n1. Install devbox by following the instructions in the [devbox documentation](https://www.jetify.com/devbox/docs/installing_devbox/).\n2. Clone this repository to your local machine.\n3. Navigate to the root directory of the cloned repository.\n4. Run `devbox install` to install all packages mentioned in the `devbox.json` file.\n5. Run `devbox shell --pure` to start a new shell with access to the environment.\n6. Once the devbox environment is set up, you can start developing, testing, and contributing to the repository.\n\n### Running Tasks\n\nThis project provides both a `Makefile` and a `Taskfile` for running various tasks. You can use either `make` or `task` to execute the tasks, depending on your preference.\n\nTo view all available tasks, run:\n\n- **Makefile**: `make help`\n- **Taskfile**: `task --list-all`\n\nAvailable tasks:\n\n```bash\nlive      # Run the demos live server with templ watch mode.\ntempl     # Run templ fmt and templ generate commands.\n```\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findaco%2Fteseo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findaco%2Fteseo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findaco%2Fteseo/lists"}