{"id":13794965,"url":"https://github.com/sourcegraph/docsite","last_synced_at":"2025-05-12T21:32:45.160Z","repository":{"id":33829018,"uuid":"153080223","full_name":"sourcegraph/docsite","owner":"sourcegraph","description":"The documentation site used by Sourcegraph","archived":false,"fork":false,"pushed_at":"2024-08-27T09:49:47.000Z","size":275,"stargazers_count":65,"open_issues_count":11,"forks_count":8,"subscribers_count":64,"default_branch":"main","last_synced_at":"2024-11-17T12:49:40.480Z","etag":null,"topics":["lsif-enabled"],"latest_commit_sha":null,"homepage":"https://docs.sourcegraph.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcegraph.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-10-15T08:39:46.000Z","updated_at":"2024-11-06T03:22:48.000Z","dependencies_parsed_at":"2024-01-07T06:06:27.848Z","dependency_job_id":"15b1a5de-9904-4c04-96af-130d0e7038fe","html_url":"https://github.com/sourcegraph/docsite","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fdocsite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fdocsite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fdocsite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fdocsite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcegraph","download_url":"https://codeload.github.com/sourcegraph/docsite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225157000,"owners_count":17429698,"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":["lsif-enabled"],"created_at":"2024-08-03T23:00:50.623Z","updated_at":"2025-05-12T21:32:45.140Z","avatar_url":"https://github.com/sourcegraph.png","language":"Go","funding_links":[],"categories":["Site Generators"],"sub_categories":[],"readme":"# docsite\n\nA documentation site generator that fits [Sourcegraph](https://sourcegraph.com)'s needs:\n\n- Markdown source files that are browseable on the file system and readable as plain text (without custom directives or complex front matter or configuration)\n- Served by an HTTP server, not generated as static HTML files, to eliminate the need for external static site host configuration (which we found to be error-prone)\n- Provides built-in site search for all documentation versions\n\n## Usage\n\n```shell\ngo get github.com/sourcegraph/docsite/cmd/docsite\ndocsite -h\n```\n\n- `docsite check`: check for common problems (such as broken links)\n- `docsite serve`: serve the site over HTTP\n\nTo use docsite for docs.sourcegraph.com, see \"[Documentation site](https://docs.sourcegraph.com/dev/documentation/site)\" in the Sourcegraph documentation.\n\n## Checks\n\nThe `docsite check` command runs various checks on your documentation site to find problems:\n\n- invalid links\n- broken links\n- disconnected pages (with no inlinks from other pages)\n\nIf any problems are found, it exits with a non-zero status code.\n\nTo ignore the disconnected page check for a page, add YAML `ignoreDisconnectedPageCheck: true` to the top matter in the beginning of the `.md` file. For example:\n\n```\n---\nignoreDisconnectedPageCheck: true\n---\n\n# My page title\n```\n\n## Site data\n\nThe site data describes the location of its templates, assets, and content. It is a JSON object with the following properties.\n\n- `content`: a VFS URL for the Markdown content files.\n- `contentExcludePattern`: a regular expression specifying Markdown content files to exclude.\n- `baseURLPath`: the URL path where the site is available (such as `/` or `/help/`).\n- `rootURL`: (optional) the root URL (scheme + host). Only used for rare cases where this is absolutely necessary, such as SEO tags fox example.\n- `templates`: a VFS URL for the [Go-style HTML templates](https://golang.org/pkg/html/template/) used to render site pages.\n- `assets`: a VFS URL for the static assets referred to in the HTML templates (such as CSS stylesheets).\n- `assetsBaseURLPath`: the URL path where the assets are available (such as `/assets/`).\n- `redirects`: an object mapping URL paths (such as `/my/old/page`) to redirect destination URLs (such as `/my/new/page`).\n- `check` (optional): an object containing a single property `ignoreURLPattern`, which is a [RE2 regexp](https://golang.org/pkg/regexp/syntax/) of URLs to ignore when checking for broken URLs with `docsite check`.\n- `search` (optional): an object containing a single proprety `skipIndexURLPattern`, which is a [RE2 regexp](https://golang.org/pkg/regexp/syntax/) pattern that if matching any content file URL will remove that file from the search index.\n- `forceServedDownloadedContent` (optional) (dev):  While developing locally, you might want to see how docsite performs when it downloads the doc content remotely. With this set to true, docsite will download the content instead of serving from the filesystem\n\nThe possible values for VFS URLs are:\n\n- A **relative path to a local directory** (such as `../myrepo/doc`). The path is interpreted relative to the `docsite.json` file (if it exists) or the current working directory (if site data is specified in `DOCSITE_CONFIG`).\n- An **absolute URL to a Zip archive** (with `http` or `https` scheme). The URL can contain a fragment (such as `#mydir/`) to refer to a specific directory in the archive.\n\n  If the URL fragment contains a path component `*` (such as `#*/templates/`), it matches the first top-level directory in the Zip file. (This is useful when using GitHub Zip archive URLs, such as `https://codeload.github.com/alice/myrepo/zip/myrev#*/templates/`. GitHub produces Zip archives with a top-level directory `$REPO-$REV`, such as `myrepo-myrev`, and using `#*/templates/` makes it easy to descend into that top-level directory without needing to duplicate the `myrev` in the URL fragment.)\n\n  If the URL contains the literal string `$VERSION`, it is replaced by the user's requested version from the URL (e.g., the URL path `/@foo/bar` means the version is `foo`). ⚠️ If you are using GitHub `codeload.github.com` archive URLs, be sure your URL contains `refs/heads/$VERSION` (as in `https://codeload.github.com/owner/repo/zip/refs/heads/$VERSION`), not just `$VERSION`. This prevents someone from forking your repository, pushing a commit to their fork with unauthorized content, and then crafting a URL on your documentation site that would cause users to view that unauthorized content (which may contain malicious scripts or misleading information).\n\n### Templates\n\nThe templates use [Go-style HTML templates](https://golang.org/pkg/html/template/).\n\n- Document pages are rendered using a template named `document.html`.\n- Search result pages are rendered using a template named `search.html`.\n- The file `root.html`, if it exists, is loaded when rendering any template. You can define common templates in this file.\n\nSee the following examples:\n\n- [about.sourcegraph.com/handbook templates](https://github.com/sourcegraph/about/tree/master/_resources/templates)\n- [docs.sourcegraph.com templates](https://github.com/sourcegraph/sourcegraph-public-snapshot/tree/main/doc/_resources/templates)\n\n### Redirects\n\nIn addition to the `redirects` property in site data, you can also specify redirects in a text file named `redirects` at the top level of the `assets` VFS. The format is as follows:\n\n```text\nFROM-PATH TO-URL STATUS-CODE\n```\n\nFor example:\n\n```text\n# Comments are allowed\n/my/old/page /my/new/page 308\n/another/page https://example.com/page 308\n```\n\n### Specifying site data\n\nThe `docsite` tool requires site data to be available in any of the following ways:\n\n- A `docsite.json` file (or other file specified in the `-config` flag's search paths), as in the following example:\n  ```json\n  {\n    \"content\": \"../sourcegraph/doc\",\n    \"baseURLPath\": \"/\",\n    \"templates\": \"templates\",\n    \"assets\": \"assets\",\n    \"assetsBaseURLPath\": \"/assets/\",\n    \"check\": {\n      \"ignoreURLPattern\": \"(^https?://)|(^#)|(^mailto:support@sourcegraph\\\\.com$)|(^chrome://)\"\n    }\n  }\n  ```\n- In the `DOCSITE_CONFIG` env var, using Zip archive URLs for `templates`, `assets`, and `content`, as in the following example:\n  ```\n  DOCSITE_CONFIG='{\"templates\":\"https://codeload.github.com/sourcegraph/sourcegraph-public-snapshot/zip/refs/heads/main#*/doc/_resources/templates/\",\"assets\":\"https://codeload.github.com/sourcegraph/sourcegraph/zip/refs/heads/main#*/doc/_resources/assets/\",\"content\":\"https://codeload.github.com/sourcegraph/sourcegraph/zip/refs/heads/$VERSION#*/doc/\",\"baseURLPath\":\"/\",\"assetsBaseURLPath\":\"/assets/\",\"defaultContentBranch\":\"main\"}' docsite serve\n  ```\n\n## Development\n\n## Running locally\n\nTo run docsite locally and serve on port `:5080`, run:\n\n```shell\ngo run ./cmd/docsite/... -config docsite.json serve\n```\n\n### Force serving downloaded content\n\nFor certain use cases you want to have docsite download the docs content as it does with production configuration. To force this behaviour locally you can set `\"forceServedDownloadedContent\": true` in you `docsite.json` configuration\n\n### Release a new version\n\n1. Build the Docker image for `linux/amd64`:\n\n   ```sh\n   docker build -t sourcegraph/docsite .\n\n   # Use buildx if you're on M1\n   docker buildx build --platform linux/amd64 -t sourcegraph/docsite .\n   ```\n\n1. Tag and push the image to Docker Hub and GCR:\n   ```sh\n   export VERSION= # e.g. v1.9.1\n   docker tag sourcegraph/docsite sourcegraph/docsite:$VERSION\n   docker push sourcegraph/docsite\n   docker push sourcegraph/docsite:$VERSION\n   ```\n1. For internal Sourcegraph usage:\n   1. Bump the deployed version by updating the SHA-256 image digest in [all files that define `sourcegraph/docsite:latest@sha256`](https://sourcegraph.sourcegraph.com/search?q=context:global+repo:%5Egithub.com/sourcegraph/*+%28NOT+repo:sourcegraph/kube-backup%29+index.docker.io/sourcegraph/docsite:v.*%40sha256:.*\u0026patternType=regexp\u0026sm=1\u0026groupBy=path).\n   1. Once the pull request is merged, wait for the [Buildkite build to pass](https://buildkite.com/sourcegraph/deploy-sourcegraph-cloud/builds?branch=release).\n1. For development, bump the version number in [files that define `DOCSITE_VERSION`](https://sourcegraph.com/search?q=context:global+repo:%5Egithub.com/sourcegraph/*+%28NOT+repo:sourcegraph/kube-backup%29+DOCSITE_VERSION:\u0026patternType=literal).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fdocsite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcegraph%2Fdocsite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fdocsite/lists"}