Creating a portfolio website in Vue.js involves setting up a project, designing components, and deploying the site. Here's a step-by-step guide with code examples:
1. Setup Vue Project
Install Vue CLI (if not already):
bash Copy code
npm install -g @vue/cli
Create a new project:
bash Copy code
vue create portfolio-website
cd portfolio-website
Select features: Choose Babel, Router, and Default (Vue 3) when prompted.
2. Project Structure
After setup, your project will look like:
code Copy code
src/
├── assets/ # Images, fonts
├── components/ # Reusable components
├── views/ # Page components
├── router.js # Vue Router config
├── App.vue # Root component
└── main.js # Entry point
3. Install Dependencies
Install Vuetify (Material Design framework) for styling:
bash Copy code
vue add vuetify
Or use plain CSS/SCSS for custom styling.
4. Create Components
Views
Create pages in views/:
views/Home.vue
views/About.vue
views/Projects.vue
views/Contact.vue
Example views/Home.vue:
vue Copy code
<template>
<v-container>
<h1>Welcome to My Portfolio</h1>
<p>I'm a full-stack developer passionate about building web apps.</p>
</v-container>
</template>
Projects Grid
Example views/Projects.vue with Vuetify cards:
vue Copy code
<template>
<v-container>
<h2>My Projects</h2>
<v-row>
<v-col v-for="project in projects" :key="project.id" cols="12" sm="6" md="4">
<v-card>
<v-img :src="project.image" height="200px"></v-img>
<v-card-title>{{ project.title }}</v-card-title>
<v-card-text>{{ project.description }}</v-card-text>
</v-card>
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
data() {
return {
projects: [
{
id: 1,
title: "E-commerce App",
description: "Built with Vue.js and Firebase",
image: require("../assets/project1.jpg"),
},
// Add more projects
],
};
},
};
</script>
5. Configure Vue Router
In router.js:
js Copy code
import { createRouter, createWebHistory } from 'vue-router'
import Home from './views/Home.vue'
import About from './views/About.vue'
import Projects from './views/Projects.vue'
import Contact from './views/Contact.vue'
const routes = [
{ path: '/', component: Home },
{ path: '/about', component: About },
{ path: '/projects', component: Projects },
{ path: '/contact', component: Contact },
]
const router = createRouter({
history: createWebHistory(),
routes,
})
export default router
6. Navigation Bar
Update App.vue:
vue Copy code
<template>
<v-app>
<v-navigation-drawer v-model="drawer" app>
<v-list>
<v-list-item v-for="link in links" :key="link.text" :to="link.path">
<v-list-item-content>
<v-list-item-title>{{ link.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar app color="primary" dark>
<v-toolbar-side-icon @click="drawer = !drawer"></v-toolbar-side-icon>
<v-toolbar-title>My Portfolio</v-toolbar-title>
</v-app-bar>
<v-main>
<router-view></router-view>
</v-main>
</v-app>
</template>
<script>
export default {
data() {
return {
drawer: false,
links: [
{ text: 'Home', path: '/' },
{ text: 'About', path: '/about' },
{ text: 'Projects', path: '/projects' },
{ text: 'Contact', path: '/contact' },
],
};
},
};
</script>
7. Add Animations
Use Vue's <transition> for page transitions:
vue Copy code
<v-main>
<transition name="fade" mode="out-in">
<router-view></router-view>
</transition>
</v-main>
Add CSS:
css Copy code
.fade-enter-active, .fade-leave-active {
transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to {
opacity: 0;
}
8. Deploy the Website
Build the project:
bash Copy code
npm run build
Deploy to Netlify or Vercel :
bash Copy code
# Example for Netlify
npm install -g netlify-cli
netlify deploy --prod
For GitHub Pages:
bash Copy code
npm install gh-pages --save-dev
Add a deploy script in package.json:
json Copy code
"scripts": {
"deploy": "gh-pages -d dist"
}
9. Optional Features
Dark Mode : Use Vuetify's theme system or a custom toggle.
Blog Integration : Use Markdown files or a headless CMS.
SEO : Install vue-meta for dynamic meta tags.
Final Result
You’ll have a responsive portfolio with:
A navigation drawer
Sections for home, about, projects, and contact
Smooth transitions
Modern styling via Vuetify
Let me know if you want a version without Vuetify or with specific features! 🚀