# Taragen manual Taragen is a fast, minimal static site generator distributed as a single binary. You write pages in JSX, Markdown, or Go templates, arrange them in folders, and taragen turns the folder into a website. There is no config file, no Node.js, and no `node_modules`: the file tree is the configuration, and JSX runs in a JavaScript engine built into the binary. Why taragen: - **Write in the format that fits.** Markdown for writing, JSX for pages with logic, Go templates if you like them, all in the same site. - **Components without a framework.** JSX layouts and partials let you build a site from reusable pieces, rendered to plain HTML with nothing shipped to the browser. - **Live reloading.** `taragen serve` notices every change and refreshes the browser for you. - **One binary.** Install it and you're done. Nothing to `npm install`, nothing to keep updated. This manual is for people building sites with taragen. It covers every feature, from a first page to generated archives, backlinks, redirects, and share cards, and ends with [tutorials](#tutorials) that put them together. ## Contents 1. [Install](#install) 2. [Quick start](#quick-start) 3. [Commands](#commands) 4. [How a site is laid out](#how-a-site-is-laid-out) 5. [Pages](#pages) 6. [Page data](#page-data) 7. [Defaults and globals](#defaults-and-globals) 8. [Layouts](#layouts) 9. [Partials](#partials) 10. [Writing JSX](#writing-jsx) 11. [Markdown](#markdown) 12. [Go templates](#go-templates) 13. [Listing pages with `pages()`](#listing-pages-with-pages) 14. [Drafts](#drafts) 15. [Static files and assets](#static-files-and-assets) 16. [Non-HTML pages and feeds](#non-html-pages-and-feeds) 17. [Extra outputs per page](#extra-outputs-per-page) 18. [Share cards](#share-cards) 19. [Generated pages](#generated-pages) 20. [Backlinks](#backlinks) 21. [Aliases and redirects](#aliases-and-redirects) 22. [Code highlighting](#code-highlighting) 23. [Building and deploying](#building-and-deploying) 24. [Serve mode and live reload](#serve-mode-and-live-reload) 25. [Tutorials](#tutorials) 26. [Errors and troubleshooting](#errors-and-troubleshooting) 27. [Reference](#reference) ## Install With Homebrew: ```sh brew tap progrium/homebrew-taps brew install taragen ``` Or download a release binary for your platform (macOS, Linux, and Windows, on amd64 and arm64) from the GitHub releases page and put it on your `PATH`. To build from source you need only Go: ```sh make build # writes .local/bin/taragen make link # symlinks it into /usr/local/bin ``` ## Quick start Make a folder for your site, and in it an `index.jsx`: ```jsx
Latest posts:
{partial("_partials/latest")} ``` A `data({...})` call at the very top of the file (after whitespace and comments) sets page data. The trailing `;` is optional. `data()` merges its object into both `page` and the page's data, so later code in the file and the layouts see it. In a [generated page template](#generated-pages), a `params(...)` call can sit alongside `data()` in these leading statements. ### Values in JSX Children can be elements, strings, numbers, or arrays (flattened, so `.map(...)` works). `null`, `undefined`, `true`, and `false` render nothing, so conditionals work: ```jsx {page.draft && Draft} {page.tags?.map(t => {t})} ``` Attribute values can be: | Value | Result | | --- | --- | | string | `name="value"`; an empty string omits the attribute | | number | Printed as JS prints it | | `true` / `false` | Bare attribute (``) / omitted | | object | Serialized as a `style` string: `style={{ color: "red", "font-size": "2em" }}` | | `null` / `undefined` | Omitted | Anything else, such as an object as a child or a function as an attribute, throws a `TypeError` and fails the render. Attributes are written in the order you wrote them, and the output is identical on every build, so diffs of `_public/` show only real changes. Void elements like `