--- title: "From Idea to Interaction:\n A Modern Template for Scientific Writing " subtitle: "Markdown-first research article template with math, citations, and interactive figures." description: "A modern, MDX-first research article template with math, citations, and interactive figures." authors: - "John Doe" - "Alice Martin" - "Robert Brown" affiliation: "Hugging Face" published: "Feb 19, 2025" tags: - research - template ogImage: "https://example.com/your-og-image.png" --- import HtmlFragment from "../components/HtmlFragment.astro"; import Wide from "../components/Wide.astro"; import FullBleed from "../components/FullBleed.astro"; import { Image } from 'astro:assets'; import placeholder from "../assets/images/placeholder.jpg"; import audioDemo from "../assets/audio/audio-example.wav"; import Aside from "../components/Aside.astro"; import visualPoster from "../assets/images/visual-vocabulary-poster.png"; This template is inspired by [**Distill**](https://distill.pub); we aim to preserve the best of it while modernizing the stack. Their work is highly inspiring. #### Features
Markdown based KaTeX math Syntax highlighting Citations & footnotes Automatic build Table of content Dark theme HTML fragments Plotly ready D3.js ready SEO Friendly Lightweight bundle Aside notes Mobile friendly Optimized images Medium like zoomable images PDF export
## Getting Started ### Installation ```bash git lfs install git lfs pull cd app npm install ``` ### Development ```bash npm run dev ``` ### Build ```bash npm run build ``` Serving the `dist/` directory on any static host is enough to deliver the site. ### Deploy The easiest way to get online is to clone [this Hugging Face Space](https://huggingface.co/spaces/tfrere/science-blog-template) and push your changes; every push triggers an automatic build and deploy. ### Large files (Git LFS) **Track binaries** (e.g., `.png`, `.wav`) with **Git LFS** to keep the repository lean. This project is preconfigured to store such files via **LFS**. ## Writing Your Content ### Introduction Your article lives in two places: - `app/src/content/` — where you can find the article.mdx, bibliography.bib and html fragments. - `app/src/assets/` — images, audio, and other static assets. (handled by git lfs) This is MDX, its basically a markdown file with html and astro components. The **initial skeleton** of an article looks like this. ```mdx {/* HEADER */} --- title: "This is the main title" subtitle: "This will be displayed just below the banner" description: "A modern, MDX-first research article template with math, citations, and interactive figures." authors: - "John Doe" - "Alice Martin" - "Robert Brown" affiliation: "Hugging Face" published: "Feb 19, 2025" tags: - research - template ogImage: "https://example.com/your-og-image.png" --- {/* IMPORTS */} import { Image } from 'astro:assets'; import placeholder from '../assets/images/placeholder.jpg'; {/* CONTENT */} # Hello, world This is a short paragraph written in Markdown. Below is an example image: Example image ``` **Available blocks**:
Math Images Code Citations & notes Asides Array Audio Interactive fragments TrackIO
### Math **Inline** $x^2 + y^2 = z^2$. ```mdx $x^2 + y^2 = z^2$ ``` **Block** $$ \mathrm{Attention}(Q,K,V)=\mathrm{softmax}\!\left(\frac{QK^\top}{\sqrt{d_k}}\right) V $$ ```mdx $$ \mathrm{Attention}(Q,K,V)=\mathrm{softmax}\!\left(\frac{QK^\top}{\sqrt{d_k}}\right) V $$ ``` ### Images **Responsive images** automatically generate an optimized `srcset` and `sizes` so the browser downloads the most appropriate file for the current viewport and DPR. You can also request multiple output formats (e.g., **AVIF**, **WebP**, fallback **PNG/JPEG**) and control **lazy loading/decoding** for better **performance**. **Optional:** Zoomable (Medium-like lightbox): add `data-zoomable` to opt-in. Only images with this attribute will open full-screen on click. **Optional:** Lazy loading: add `loading="lazy"` to opt-in. **Optional:** Figcaption and credits: add a `figcaption` element with a `span` containing the credit.
Example with caption and credit
Optimized image with a descriptive caption. Credit: Photo by Author
```mdx import { Image } from 'astro:assets' import myImage from '../assets/images/placeholder.jpg' Responsive, optimized example image
Example with caption and credit
Optimized image with a descriptive caption. Credit: Photo by Author
``` ### Code blocks Use fenced code blocks with a language for syntax highlighting. Python block example: ```python def greet(name: str) -> None: print(f"Hello, {name}!") greet("Astro") ``` How to write it in MDX: ````mdx ```python def greet(name: str) -> None: print(f"Hello, {name}!") greet("Astro") ``` ```` ### Citations and notes Here are a few variations using the same bibliography: 1) **In-text citation** with brackets: [@example2023]. 2) **Narrative citation**: As shown by @vaswani2017attention, transformers enable efficient sequence modeling. 3) **Multiple citations** and a **footnote** together: see [@vaswani2017attention; @example2023] for related work. Also note this footnote[^f1]. [^f1]: Footnote attached to the sentence above. ```mdx 1) In-text citation with brackets: [@example2023]. 2) Narrative citation: As shown by @vaswani2017attention, transformers enable efficient sequence modeling. 3) Multiple citations and a footnote together: see [@vaswani2017attention; @example2023] for related work. Also note this footnote[^f1]. [^f1]: Footnote attached to the sentence above. ``` ### Asides ```mdx import Aside from '../components/Aside.astro' ``` ### Width helpers Use these helpers to expand content beyond the main column when needed. They will always be centered and displayed above every other content. #### Wide example
demo wide
```mdx import Wide from '../components/Wide.astro' Your content here... ``` #### Full-bleed example
demo full-bleed
```mdx import FullBleed from '../components/FullBleed.astro' Your content here... ``` ### Minimal table | Method | Score | |---|---| | A | 0.78 | | B | 0.86 | ```mdx | Method | Score | | --- | --- | | A | 0.78 | | B | 0.86 | ``` ### Audio ```mdx import audioDemo from '../assets/audio/audio-example.wav' ``` ### Embeds #### Html Fragments The main purpose of the ```HtmlFragment``` component is to embed a **Plotly** or **D3.js** chart in your article. Libraries are already imported in the template.
```mdx import HtmlFragment from '../components/HtmlFragment.astro' ``` #### Iframes You can embed external content in your article using **iframes**. For example, **TrackIO**—a lightweight dashboard to monitor machine learning experiments—can be used this way. The example below opens a demo project and displays a couple of metrics. You can customize the **query parameters** (`project`, `metrics`, `sidebar`, etc.) to fit your needs. To embed TrackIO in your own page, copy the following HTML and adjust the `src` parameters: #### GitHub code embeds Finally, if you want to include code from GitHub you can use emgithub.com and, for example, create a collapsible widget like this:
```html
``` ## Best Practices ### Short sections Break content into **small, purpose‑driven sections**. Each section should answer a **single question** or support one idea. This improves **scanability**, helps readers navigate with the TOC, and makes later edits safer. ### Clear, minimal annotations Favor **concise captions** and callouts that clarify what to look at and why it matters. In code, **highlight just the lines** that carry the idea; avoid verbose commentary. **Precision beats volume**. ### Explain math notation **Introduce symbols and variables** the first time they appear, and prefer **well‑known identities** over custom shorthand. When formulas carry the message, add one sentence of **plain‑language interpretation** right after. ### Use the right color scale Choosing colors well is critical: a **palette** encodes **meaning** (categories, magnitudes, oppositions), preserves **readability** and **accessibility** (**sufficient contrast**, **color‑vision safety**), and ensures **perceptually smooth transitions**. The three families below illustrate when to use **categorical**, **sequential**, or **diverging** colors and how they evolve from the same **reference hue**.
### Use the right chart Picking the right visualization depends on your goal (compare values, show distribution, part-to-whole, trends, relationships, etc.). The Visual Vocabulary poster below provides a concise mapping from **analytical task** to **chart types**.
Visual Vocabulary: choosing the right chart by task
A handy reference to select chart types by purpose. Click to enlarge. — Website
## Conclusions This template provides a **practical baseline** for writing and sharing technical articles with **math**, **citations**, and **interactive figures**. **Start simple**, **iterate** on structure and style, and keep content **maintainable** for future readers and collaborators.