This gallery is live on: https://ritog.github.io/books/
It stores a collection of books I've read and want to read, showcasing them in a beautiful, responsive gallery format.
You can use the code for your own books gallery by editing the books.js file. It is free, needs no backend, and requires no build command.
A responsive book gallery website with filtering by tags, languages, and reading status, plus one simple JavaScript data file.
- Beautiful Grid Layout: Responsive book cover grid that adapts to any screen size
- Always-visible Details: Book information works with a mouse, keyboard, or touchscreen
- Advanced Filtering: Filter by tags, languages, and reading status (Read, Reading, Want to Read)
- Search Functionality: Search through titles and authors
- Multi-language Support: Display books in different languages
- Reading Statistics: Track total books, read, reading, and want-to-read counts
- Easy Data Management: Add or remove entries in one
books.jsfile - Local Cover Support: Use local image files for book covers (e.g.,
assets/covers/my-book.jpg) - Zero Maintenance: Static site that works without any backend
- Clone or download this repository
- Open
index.htmlin your browser - Start customizing by editing
books.js
That is it. The complete library works both when opened directly and when hosted.
Using a local server is optional. If you prefer one, run python -m http.server 8000 and open http://localhost:8000.
Edit the books array inside books.js:
window.BOOKS_DATA = {
"books": [
{
"title": "Book Title",
"author": "Author Name",
"cover": "https://example.com/cover.jpg",
"rating": 5,
"dateRead": "2024-01-15",
"tags": ["Fantasy", "Adventure"],
"language": "EN",
"status": "read",
"review": "https://goodreads.com/review/123",
"format": "paper"
}
]
};The project includes a dependency-free validator. It uses only Node.js itself;
you do not need to run npm install or download any packages.
- Save your changes to
books.js. - Open a terminal in this project folder.
- Run:
node validate-books.jsThe validator checks required fields, calendar dates, allowed statuses, rating ranges and quarter-point steps, duplicated tags/books, suspicious corrupted Bengali text, and every local cover path.
ERRORmeans the data can break or mislead the site. Fix it and run the command again.WARNINGmeans the data is usable but incomplete, such as a read book without a rating.- Warnings do not fail validation. Errors return a failing exit code, so the script can also be used in automation later without changing it.
The recommended hobby-project workflow is simply: edit books.js, run the
validator once, and then commit or publish the change.
| Field | Type | Description | Example |
|---|---|---|---|
title |
string | Book title | "Dune" |
author |
string | Author name | "Frank Herbert" |
cover |
string | Cover image URL/local file relative path | "https://example.com/cover.jpg" |
rating |
number | Your rating (1-5) | 5 |
dateRead |
string/null | Date finished (YYYY-MM-DD) | "2024-01-15" |
tags |
array | Book categories | ["Sci-Fi", "Classic"] |
language |
string | Language code | "EN", "ES", "FR" |
status |
string | "read", "reading", or "want-to-read" | "read" |
review |
string/null | Review link | "https://substack.com/..." |
format |
string/null | Format of the book (paper, ebook, audio) | "paper" |
EN- EnglishES- SpanishDE- GermanSA- SanskritBN- BengaliHI- Hindi
(You can add more languages as needed)
- Create a new repository on GitHub
- Upload all files to the repository
- Go to Settings β Pages
- Select source: "Deploy from a branch"
- Choose branch:
mainormaster - Save - Your site will be live at
https://username.github.io/repository-name
- Sign up for Cloudflare Pages
- Connect your GitHub repository
- Deploy - Your site will be live instantly
- Drag and drop the folder to netlify.com
- Your site is live immediately
Edit styles.css to customize:
- Background gradient
- Card colors
- Hover effects
- Typography
Modify the grid layout in styles.css:
.books-grid {
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 2rem;
}The JavaScript in script.js is modular and easy to extend:
- Add new filter types
- Implement sorting
- Add book details modal
- Create reading lists
The site automatically adapts to:
- Desktop: Full grid layout
- Tablet: Adjusted spacing and sizing
- Mobile: Two-column status buttons, always-visible library statistics, collapsible search/filter controls, and a responsive book grid
The library statistics must be visible as soon as the page loads on every
screen size. They are informational content, so a visitor should never need to
press Filters to discover them. Only the search box and filter controls are
collapsed on screens up to 768px wide.
The implementation is split into three small responsibilities:
index.htmlprovides the structure. The.statspanel and#sidebarControlsare separate siblings inside.sidebar. Add future search or filter controls inside#sidebarControls; do not put the statistics there.styles.csscontrols visibility. Inside themax-width: 768pxmedia query,.sidebar-controlsis hidden and.sidebar-controls.openis visible. Desktop has no hiding rule, so its sidebar stays visible as before.script.jshandles the button. Pressing#sidebarToggletoggles theopenclass on#sidebarControlsand updatesaria-expandedfor assistive technology. The book totals themselves are still calculated once byupdateStats(); there is no duplicate mobile data or markup to maintain.
The button's aria-controls="sidebarControls" value must match the wrapper's
id="sidebarControls". If either name changes, update both places.
- Open the page and make the browser narrower than
768px. - Confirm the four statistics appear immediately and the search box is hidden.
- Press Filters. Confirm search and Filter options appear while the statistics remain visible.
- Widen the browser beyond
768px. Confirm the Filters button disappears and the statistics, search box, and Filter options remain visible in the sidebar.
- Check that cover URLs are accessible
- Use placeholder images for missing covers
- Ensure URLs are HTTPS for security
- Check for missing commas or brackets
- Keep
window.BOOKS_DATA =at the beginning and;at the end - Ensure all required fields are present
- A local server is optional; opening
index.htmldirectly also works - Python:
python -m http.server 8000[I used this one] - Node.js:
npx serve
This project is open source and available under the Apache License, Version 2.0.
Feel free to fork the project, and add your own features or improvements! I am not looking to extend this project.
If you need help:
- Check the troubleshooting section
- Look at the existing entries in
books.js - Open an issue on GitHub
Story Book icon by Icons8
Happy Reading! πβ¨
