React SEO Breadcrumb is a customizable breadcrumb component that integrates schema markup for SEO optimization. It allows you to build breadcrumbs for your website with enhanced SEO support, ensuring better search engine indexing and user experience.
- SEO-friendly with schema.org markup for improved search engine indexing.
- Customizable styles via Tailwind CSS.
- Flexible configuration for breadcrumb items, separators, and icons.
- Truncation support for long titles with ellipsis.
- Home breadcrumb toggle: Optionally disable the Home breadcrumb.
To install the package, run:
npm install react-seo-breadcrumb
To use react-seo-breadcrumb, make sure your project has Tailwind CSS configured. If not, follow these steps:
- Install Tailwind CSS:
npm install -D tailwindcss postcss autoprefixer
- Initialize Tailwind CSS configuration:
npx tailwindcss init
- Create a
tailwind.config.js
file (if it’s not automatically generated), and configure yourcontent
property to include your React component files:
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}", // adjust based on your project structure
],
theme: {
extend: {},
},
plugins: [],
};
- Create a
postcss.config.js
file in your project root if you don't have one already, and include the following:
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
- Create a
src/tailwind.css
file with the following content to import the Tailwind CSS base styles:
/* src/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
- Import this
tailwind.css
file into your mainindex.js
orApp.js
file:
import './tailwind.css';
-
Create a
breadcrumbItems
array: This array will contain the objects representing each breadcrumb item.Example
breadcrumbItems
array:
const breadcrumbItems = [
{ title: "Home", link: "/" },
{ title: "Videos", link: "/videos" },
{ title: "Video Title", link: "/video-id" }
];
- Use the Breadcrumb component in your React component:
import Breadcrumb from 'react-seo-breadcrumb';
const App = () => {
const breadcrumbItems = [
{ title: "Home", link: "/" },
{ title: "Videos", link: "/videos" },
{ title: "Video Title", link: "/video-id" }
];
return (
<div>
<Breadcrumb items={breadcrumbItems} />
</div>
);
};
export default App;
The Breadcrumb
component accepts the following props:
Prop | Type | Default value | Description |
---|---|---|---|
item |
Array |
Required | Array of breadcrumb items (title, link, and optional colorDisable). |
disableHome |
Boolean |
false |
if true , hides the "Home" breadcrumb. |
changeDefaultColor |
String |
"text-blue-700" |
Default color for breadcrmb items. |
changeActivityColor |
String |
"text-gray-700" |
Color for the breadcrumb separators. |
changeDefaultIcon |
String |
">" |
Separator icon between breadcrumb items. |
needSchema |
Boolean |
true |
If true , adds schema.org makup to breadcrumbs. |
schemaItemProp |
String |
"ListItem" |
Schema markup item property (e.g., ListItem ). |
schemaItemType |
String |
"Thing" |
Schema markup item type (e.g., Thing ). |
needEllipsisIfLong |
Boolean |
true |
If true , truncates breadcrumb titles longer than ellipsisLength . |
ellipsisLength |
Number |
25 |
Maximum length for breadcrumb title before truncation. |
fontBold |
Boolean |
false |
If true , pplies bold styling to breadcrub items. |
activeItemBold |
Boolean |
false |
If true , the active breadcrumb item will be bolded. |
Basic Example
import Breadcrumb from 'react-seo-breadcrumb';
const breadcrumbItems = [
{ title: "Home", link: "/" },
{ title: "Videos", link: "/videos" },
{ title: "Video Title", link: "/video-id" }
];
const App = () => (
<div>
<Breadcrumb items={breadcrumbItems} />
</div>
);
import Breadcrumb from 'react-seo-breadcrumb';
const breadcrumbItems = [
{ title: "Home", link: "/" },
{ title: "Videos", link: "/videos" },
{ title: "Video Title", link: "/video-id" }
];
const App = () => (
<div>
<Breadcrumb
items={breadcrumbItems}
disableHome={false}
changeDefaultColor="text-blue-700"
changeActivityColor="text-gray-700"
changeDefaultIcon=">"
needEllipsisIfLong={true}
ellipsisLength={30}
/>
</div>
);
<Breadcrumb items={breadcrumbItems} needEllipsisIfLong={false} />
<Breadcrumb
items={breadcrumbItems}
needSchema={true}
schemaItemProp="ListItem"
schemaItemType="Thing"
/>
<Breadcrumb items={breadcrumbItems} changeDefaultIcon="|" />
<Breadcrumb items={breadcrumbItems} disableHome={true} />
Breadcrumbs enhance user navigation and provide substantial SEO benefits. By implementing schema.org markup for breadcrumbs, search engines like Google can better understand your site's structure. This leads to better indexing, visibility in search results, and improved rankings.
-
Enhanced Website Organization: Breadcrumbs help both users and search engines identify page relationships.
-
Improved Search Engine Visibility: Search engines use breadcrumbs to understand content hierarchy.
-
Better User Experience: Breadcrumbs improve navigation, particularly for larger websites.
If you encounter any problems, have questions, or want to request features, feel free to reach out via:
- GitHub Issues: Report an Issue
- Email: neel.chavda104@gmail.com
- Contributions: Contributions are welcome! Please follow the Contribution Guidelines.
React, Breadcrumb, SEO Breadcrumb, React Component, Tailwind CSS Breadcrumb, Structured Data, Navigation, React SEO, SEO-friendly