The Wayback Machine - https://web.archive.org/web/20240717024600/https://www.geeksforgeeks.org/travel-blog-website-using-react/
Open In App

Travel Blog Website using React

Last Updated : 08 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Creating a Travel Blog Website using React JS is a better way to learn how to manage state, passing props and render data dynamically. In this article, we are going to learn how to create a Travel Blog Website using React JS. This website will have a list of places with images and description. The data is passed through the application with the help of JSON file. When you click on the location, it will redirect you to the google maps to see the complete description of that place.

Preview of final output: Let us have a look at how the final output will look like.

ezgifcom-video-to-gif

Travel Blog using ReactJS

Prerequisites

  • Knowledge of React
  • HTML and CSS
  • Node and NPM/Yarn installed.

Approach

  • First we will create a data.js file which will store all the data of the travel places like location, images, description etc.
  • After that we will create header and footer for the website.
  • Now we will create the cards section which will display the travel places.
  • We will pass the data stored in the data.js file as props.
  • Now we will integrate all the components in the App.js file.
  • To style the app we will add the required style in the App.css file.

Steps to create React Application And Installing Module:

Step 1: Setting up the React Project

npx create-react-app travelblog

Step 2: After creating your project folder, move to it using the following command.

cd travelblog

Step 3: Create an image folder and store your custom images in the public folder.

Project Structure:

travelbloggfg

The updated dependencies in package.json file will look like

"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"mdbreact": "^5.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}

Example: Create and add the codes in the respective files.

Javascript




//App.js
 
import Header from './components/Header.js'
import Cards from './components/Cards.js'
import { data } from './data.js'
import Footer from './components/Footer.js'
import './App.css'
 
function App() {
    const mappedData = data.map((item) => {
        return (
            <Cards key={item.id} item={item} />
        )
    })
    return (
        <div className="App">
            <Header />
            {mappedData}
            <Footer />
        </div>
    );
}
 
export default App;


Javascript




//Cards.js
 
import React from 'react';
 
 
export default function Cards(props) {
    return (
        <div className='card'>
            <section className='column-left'>
                <img className="card-img" src="./images/coverImg" alt="images" />
            </section>
            <section className='column-right'>
                <span className='material-symbols-outlined'>location_on</span>
                <span className="card-country">{props.item.country} </span>
                <a href={props.item.googleMapLink}>View on Google Maps</a>
                <h3 className="card-country-title">{props.item.title}</h3>
                <h4 className="card-date">{props.item.date}</h4>
                <p>{props.item.description}</p>
                <span>Read more..</span>
            </section>
 
        </div>
    )
}


Javascript




//Header.js
 
import React from "react";
 
export default function Header() {
    return (
        <div>
            <header className="journal-header">
                <h1 className="title">my travel journal</h1>
            </header>
        </div>
    )
}


Javascript




//Footer.js
 
import React from 'react';
 
export default function Footer() {
    return (
        <div className='journal-footer'>
            <caption>Ingrid G. 2023 |</caption>
            <caption className='footer-caption'> Favicon by: </caption>
        </div>
    )
};


Javascript




//data.js
 
export const data = [
    {
        id: 1,
        date: "May 2018",
        title: "Panajachel, Lake Atitlán",
        description:
"The busiest and most built-up lakeside town, Panajachel ('Pana') is the gateway to Lago de Atitlán for most travelers.",
        coverImg: "atitlan.jpeg",
        country: "GUATEMALA",
        googleMapLink:
"https://www.google.com/maps/place/Lake+Atitl%C3%A1n/@14.6788007,-91.2837663,12z/data=!3m1!4b1!4m6!3m5!1s0x85894ac7c083b493:0xa6e33f7d6b54910!8m2!3d14.6906713!4d-91.2025207!16zL20vMDN3NXpy?entry=ttu",
    },
    {
        id: 2,
        date: "December 2019",
        title: "Secret Beach",
        description:
"Experience the beautiful landscape and meet new friends all while enjoying pristine warm waves of the Atlantic.",
        coverImg: "belize.jpeg",
        country: "BELIZE",
        googleMapLink:
"https://www.google.com/maps/search/belize+secret+beach/@18.0171292,-87.9672513,13z/data=!3m1!4b1?entry=ttu",
    }
]


CSS




/* App.css*/
 
* {
  box-sizing: border-box;
}
 
body {
  margin: 0;
  font-family: 'Outfit', sans-serif;
   
}
 
a {
  color: #d74180;
  font-size: 16px;
}
 
a:hover{
  color: #808080;
}
 
section {
  padding: 20px;
}
 
p {
  font-size: 16px;
}
 
h4, p {
  padding-bottom:5px;
  margin: 0;
}
 
.title {
  font-weight: 600;
}
 
.journal-header {
  background-color: #d74180;
  height: 130px;
  justify-content: center;
  align-items: center;
  display: flex;
  padding: 20px 36px;
  color: white;
  margin-left: 40px;
  margin-right: 40px;
}
 
/* .material-symbols-outlined {
  font-variation-settings:
    'wght' 200,
    'GRAD' 20,
    'opsz' 24,
} */
 
.card-img {
 
  min-width: 300px;
  border-radius: 9px;
  margin-bottom: 15px;
  position: relative;
  padding-left: 10px;
  display: block;
}
 
.card-country {
  font-size: 18px;
  padding-right: 10px;
}
 
.card-country-title {
  font-size: 40px;
}
 
.card-date {
  font-size: 18px;
}
 
.card {
  /* align-items: center; */
  /* width: 175px; */
  display: flex;
  flex-direction: row;
  font-size: 12px;
  flex: 0 0 auto;
  position: relative;
  margin-top: 80px;
  margin-right: 15px;
  margin-left: 15px;
   
   
}
 
.column-left {
  flex: 40%;
  padding-right: 30px;
}
 
.column-right {
  flex: 40%;
}
 
.journal-footer {
  justify-content: center;
  align-items: center;
  display: flex;
  background-color: #5a595a;
  height: 130px;
 
  display: flex;
  color: white;
  clear: both;
  position: relative;
  bottom: 0;
  width: 100%;
}
 
.footer-caption {
  padding-left: 5px;
}
 
/* For mobile phones: */
[class*="card-"] {
  width: 100%;
  flex-direction: column;
 
}
 
/* media queries */
@media (max-width: 400px) {
  .card {
    background-color: #de3163;
  }
}


To run the app run the following command in the terminal

npm start

Output:

ezgifcom-video-to-gif

Travel Blog using ReactJS



Similar Reads

How to back up and Import blog content from one blog to another Blog in Blogger ?
In this article, you will learn about how you can back up your blog posts, pages, and comments from one blog and import all the content to another blog by using the manage blog options in Blogger. This process can also be used to Back up your Blog content before deleting the blog. In the implementation what we will do is first will take the backup
2 min read
Blog Website using JavaScript
In this article, we will be creating a Blog website using JavaScript. The user can Create and Delete a post which will be displayed on the home page. The create Post modal has 3 input fields that are "Title", "Category" and "Description" of the Blog post with a Responsive Design. We will be using HTML to structure our project, CSS for designing pur
7 min read
Create a Blog Website Layout using HTML and CSS
The Blog layout consists of a header, navigation menu, main content area, and footer. The header contains the website logo, name, and its tagline. The navigation menu is used to allow users to easily navigate through the different sections of the blog. The main content area contains the list of blog posts with title, author name, published date, an
4 min read
Build Blog website using Flask
In this article, we'll explore how to build a dynamic blog website using Flask, a lightweight and versatile Python web framework. Flask provides developers with the tools needed to create robust web applications, and its simplicity makes it an excellent choice for beginners and experienced developers alike. Requirements Basics of HTML &amp; CSSBoot
15+ min read
UI Design of Travel and Tourism Website
Designing a Travel &amp; Tourism Web UI means to cover every possible method to attract users to the site in order to increase the user interactivity and dependency of the user on the site rather than opting for the conventional set of rules to book a travel. In this article we will be covering basic designing principles to create an adorable &amp;
3 min read
UI Design of a Travel ticket booking Website
A travel ticket booking website consists of several services that are provided by the website to book for tickets concerned for travel purposes, through buses, trains, flight etc. In this article we will cover some basic designing principles and how to design the UI of a travel ticket booking website with the following pages: Home, Ticket Booking P
3 min read
Creating a Travel Journal App using React
The Travel Journal App project is a web application developed using React. This travel journal app will allow users to record their travel experiences and manage their entries efficiently. By leveraging the power of React for the frontend and Bootstrap for styling, we'll create an interactive and visually appealing user interface. Preview of Final
5 min read
Developing a Budget Travel Planner using React and Interactive maps (Mapbox)
The Budget Travel Planner app is an app that aids users in planning and managing their trips within a specified budget. It helps users curate their bookings of flights, hotels, transport, etc., and also develop a schedule/itinerary to follow for their trip. This project makes use of ReactJS, Sass, and Mapbox API to come up with a beautiful frontend
15+ min read
Create a Blog App using React-Native
This article shows how to create a basic blog app using react native. This app contains functionalities such as adding a blog and a delete button to remove the blogs using react native. The user can enter content with a title and then click on 'Add New Post' to create a new blog post Preview of final output: Let us have a look at how the final outp
4 min read
Blog Page Template using React JS and Tailwind
A Blog Page is a web page that is used to display multiple blog posts on a website. Using blogs people can share their views, ideas, and opinions. A Blog Page generally contains a NavBar and Introduction followed by multiple blogs displayed in the form of a card. Prerequisites:React JSTailwind CSS propsTable of Content Basic features of a blog post
6 min read
three90RightbarBannerImg