TWCARTY (Tailwind Card Eleventy) is a starter project for photographers or artists to showcase their work and blog posts.
Clone the repository:
git clone https://github.com/sira313/twcarty
Install PNPM globally:
npm install -g pnpm
Install the project dependencies:
pnpm install
Run the project locally:
pnpm build && pnpm serve
Modify the styles (optional):
If you need to modify the CSS, run the following command in a separate terminal:
pnpm watch:css
❯ tree
├───scripts
└───src
├───asset
│ ├───blog
│ ├───index
│ └───photos
│ └───thumbnail
├───blog
├───photos
├───_data
├───_includes
│ ├───footer
│ ├───index
│ ├───js
│ ├───main
│ ├───nav
│ ├───post
│ └───search
└───_pages
├───data
├───js
├───main
└───tags
Language:
Update the language setting in src/_includes/base.html
:
<html lang="en">
Root URL:
Set your website's root URL in .eleventy.js
:
// Root URL for the share button
eleventyConfig.addGlobalData("rootURL", "https://yourwebsite.com");
Set up your social media links in src/_data/sosmed.json
.
You can use SVG icons from Feather Icons or create your own with Inkscape.
The project includes default menus for posts:
To add a new menu, follow this tutorial.
Don’t forget to update the collection in .eleventy.js
:
// Collections
const collectionConfigs = [
{ name: "posts", glob: "src/blog/**/*.md" },
{ name: "photos", glob: "src/photos/**/*.md" },
{ name: "recentPosts", glob: "src/blog/*.md", limit: 3 },
{ name: "recentPhotos", glob: "src/photos/*.md", limit: 6 }
];
Also, update your menu files:
src/_data/nav.json
for regular viewsrc/_data/nav-mobile.json
for mobile view (under 300px)The project includes three layouts in src/_includes
:
src/_includes/base.html
(used as the base for other layouts).src/_includes/post-blog.html
.src/_includes/post-photos.html
.All index pages are stored in src/_pages
:
src/index.md
(for your website’s main description).src/_pages/photos.html
(for displaying photos).src/_pages/blog.html
(for blog posts).You can automate post creation with a script, so no manual work is required. Thanks to my friend.
To create a blog post in /blog
:
pnpm mkpost -b "Your post title"
This will create a markdown file in /blog
.
To create a photo post in /photos
:
pnpm mkpost -p "Your post title"
All assets are stored in the /src/asset/
directory and referenced via front matter.
For optimal image conversion to .webp
, use Squoosh.
Although I tried using eleventy-img
, it didn’t fit my needs. You can explore it here.