Back to home

Post

My first experience with Astro

A governance page with static HTML

8 min readCarlos Araújo

A documents page seems like a simple problem: group files by category, add the links, and let the visitor expand or collapse each section.

That was the goal with which I started building a Governance page for the Brazilian Lacrosse Confederation (CBL). The first version was a standalone HTML file, with CSS and accordions. It worked, but maintenance started to catch my attention: there would be about 15 sections, with an average of five documents per section, and some of them were expected to grow. I didn't need a complex application. I needed to avoid repeating code without complicating hosting.

The context: a standalone page for a WordPress site

The main site uses WordPress, but the Governance page would be hosted separately, on a subdomain. The developer responsible for the main site would only need to add a link pointing to it. Early in the discussion, I considered possible conflicts with the WordPress theme: global styles altering buttons, spacing, or links. But that concern stopped being central once I defined the architecture.

I didn't need to insert the component inside a WordPress page. I needed to build a standalone page, with its own files and styles.

There were also two client requests:

  • The visual identity should match the current CBL site.

  • The page should organize the documents using accordions, following a certain site used as a reference.

The intention was not to reproduce the reference site, but to take advantage of an organization suited to document lists: a title per category and a control to expand or collapse the links.

The first solution: hand-written HTML

The initial implementation used <details> and <summary> to structure the accordions:

<details class="acordeao">
  <summary>Assembleias</summary>

  <div class="painel">
    <ul>
      <li>
        <a href="/documentos/ata-assembleia.pdf">
          Ata da Assembleia Geral
        </a>
      </li>
    </ul>
  </div>
</details>

The example above is simple, but the full presentation of each document included more elements:

  • Identification of the file format.

  • Document title.

  • Information about opening in a new tab.

  • Visual navigation indicator.

  • Classes to apply the styles.

With a few items, copying that structure didn't seem like a problem. But with approximately 75 documents planned, distributed across 15 sections, the repetition would become more evident. The page wasn't slow and didn't need more features. The problem was different: I would have several similar blocks to maintain.

What I wanted to improve

My goal was to separate two things that were mixed together:

  1. The visual structure of a section and of a document.

  2. The data that changes: titles, file paths, and categories.

I wanted to register a document without having to copy an HTML block. I also wanted to modify the appearance of all links by editing just one component. I considered a solution with JavaScript in the browser: keep the data in a list and build the elements from HTML templates. But I preferred to try a different flow:

Components + data
        ↓
Local generation
        ↓
HTML and CSS ready
        ↓
Publishing to hosting

That was the point at which Astro entered the project. Astro is a web framework that seeks to reduce the excess and complexity of JavaScript, when compared with other frameworks.

Why try Astro in this case?

The interest was in the possibility of working with components during development and continuing to publish static files. I didn't need authentication, an admin panel, or an application with state in the browser. The page would remain essentially an organized collection of links. The change would be in how to produce it.

That distinction was important so as not to turn the choice into an abstract comparison between tools. Hand-written HTML already solved the presentation. Astro came in to solve the organization and repetition of the source code, and there was also the learning factor: I had never used the tool. Instead of starting with an exercise without context, I could get to know it by solving a concrete problem.

The project organization

I divided the implementation into components, data, page, and styles like this:

src/
├── components/
│   ├── Acordeao.astro
│   └── Documento.astro
├── data/
│   └── documentos.json
├── pages/
│   └── index.astro
└── styles/
    └── global.css

public/
├── imagens/
│   └── logo.jpg
└── documentos/
    ├── ata-assembleia.pdf
    └── estatuto.pdf

Each of the files has its responsibility in the project:

File Responsibility
documentos.json Define the sections and the documents.
Documento.astro Present a file link.
Acordeao.astro Group documents into an expandable section.
index.astro Compose the page.
global.css Define the general styles.

That division made it possible to keep the repeated structure in a single place.

The documents became data

The content was organized in a JSON file:

[
  {
    "titulo": "Assembleias",
    "documentos": [
      {
        "titulo": "Ata da Assembleia Geral Ordinária",
        "arquivo": "/documentos/ata-assembleia.pdf",
        "formato": "PDF"
      },
      {
        "titulo": "Edital de convocação",
        "arquivo": "/documentos/edital.pdf",
        "formato": "PDF"
      }
    ]
  },
  {
    "titulo": "Documentos institucionais",
    "documentos": [
      {
        "titulo": "Estatuto social",
        "arquivo": "/documentos/estatuto.pdf",
        "formato": "PDF"
      }
    ]
  }
]

Adding a document no longer involved the visual structure, since it became a matter of providing only its data within the corresponding section. This doesn't eliminate the work of organizing the files or checking the links, but it reduces the amount of markup that needs to be handled. Since maintenance will be up to me, this flow serves the project without requiring a content management panel at this stage.

A component to present documents

The Documento.astro component concentrates the markup for each file:

---
// Code delimited by --- is called Component Script
// and runs on the server or during the build, never in the browser
interface Props {
  titulo: string;
  arquivo: string;
  formato: string;
}

const { titulo, arquivo, formato } = Astro.props;
---

<li class="documento">
  <a href={arquivo} target="_blank" rel="noopener">
    <span class="formato" aria-hidden="true">
      {formato}
    </span>

    <span class="descricao">
      <span class="titulo">{titulo}</span>
      <small>{formato} · abre em nova aba</small>
    </span>

    <span class="seta" aria-hidden="true">↗</span>
  </a>
</li>

If we want to change the description, the position of the format indicator, or the structure of the link, that is done in this file. There is no need to manually review dozens of documents to apply the same visual change.

A component to group the files

The Acordeao.astro component receives the section title and its documents:

---
import Documento from "./Documento.astro";

interface Props {
  titulo: string;
  documentos: {
    titulo: string;
    arquivo: string;
    formato: string;
  }[];
}

const { titulo, documentos } = Astro.props;
---

<details class="acordeao">
  <summary>
    <span>{titulo}</span>
    <span class="toggle" aria-hidden="true"></span>
  </summary>

  <div class="painel">
    <ul>
      {
        documentos.map((documento) => (
          <Documento {...documento} />
        ))
      }
    </ul>
  </div>
</details>

I kept the accordion structure from the initial version. I didn't need to replace everything to adopt Astro: I took advantage of what already made sense and reorganized the way the content is generated. And on the main page, the composition was reduced to reading the data and creating the sections:

---
import Acordeao from "../components/Acordeao.astro";
import secoes from "../data/documentos.json";
---

<section aria-labelledby="titulo-documentos">
  <h2 id="titulo-documentos">Documentos e publicações</h2>

  {
    secoes.map((secao) => (
      <Acordeao
        titulo={secao.titulo}
        documentos={secao.documentos}
      />
    ))
  }
</section>

The repetition still exists in the final HTML, because each section and each document must be present on the page. What I stopped repeating was the code written and maintained by hand.

The help of AI and the adjustments during development

I used AI as support in discussing the architecture and creating the first versions. The process began with a standalone HTML solution. Then, when I raised the issue of repetition, I explored the alternative with components and static generation.

It wasn't a delivery that I just copied and published without changes. Throughout the work, I made adjustments, tested the result in my environment, and investigated situations that came up while using the tools.

The cost of this choice

The solution wasn't free in terms of process. Before, I could edit an HTML file and send it directly. Now, there is a generation step between editing and publishing. Note that a change to the JSON or to a component only reaches the published page after a new build and uploading the files.

For someone who needed to update documents exclusively through an admin interface, this organization might not be enough. In my case, I am responsible for both the content and the publishing, so I accepted this additional step in exchange for centralized maintenance.

What I learned from this project

The main discovery was realizing that a page that is simple for the visitor doesn't need to have its source code maintained as a single HTML file. Nor does it mean that every small page needs a static generator.

In this case, there was a favorable combination:

  • Structure repeated across about 15 sections.

  • Approximately 75 documents planned initially.

  • A tendency to grow in some categories.

  • Content maintained by me.

  • The need to keep publishing static files.

  • An interest in learning the tool with a real problem.

The first HTML version was valid. Astro didn't make the accordion possible; it changed the way I organize and maintain the page.

For my first experience with the tool, this was a useful scope: small enough to understand the complete flow and concrete enough to evaluate the benefit of components.

Comments

Loading comments…

Leave a comment

© 2026 Do Cartão Perfurado ao Cloud