You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a website made by docusaurus 2.0.0-beta.18. I realize that, in production, when I click on items in the sidebar, it first goes to https://www.mywebsite.com/docs/a-page. If I reload the page, the url becomes https://www.mywebsite.com/docs/a-page/. This problem does not exist in localhost.
I think a url should be consistent before and after reloading. And like StackOverflow, a good style is not having / in the end. I searched issues of Docusaurus and it seems that trailingSlash would be the solution. So I added trailingSlash: false in docusaurus.config.js.
Then, I deployed this change to my production server with docker and nginx. But loading most of the pages of the website returned a 404 error, while static contents could be loaded. Reloading nginx or recreating docker containers did not help.
By contrast, setting trailingSlash: true returns well the website. And it works well: clicking on items in the sidebar goes to https://www.mywebsite.com/docs/a-page/ ended with /.
So does anyone know why trailingSlash: false makes the website return 404 error?
PS: docusaurus.config.js:
const path = require('path');
module.exports = {
title: 'my website',
tagline: 'The tagline of my site',
onBrokenLinks: 'ignore',
url: 'https://www.mywebsite.com',
baseUrl: '/', // if we use GitHub Pages, we need to set this to '/docusaurus/', and also change routing links in some pages
favicon: 'img/favicon.ico',
organizationName: 'softtimur', // Usually your GitHub org/user name.
projectName: 'docusaurus', // Usually your repo name.
trailingSlash: false,
plugins: [
path.resolve(__dirname, './plugins/monaco-loader'),
],
themeConfig: {
navbar: {
title: 'my website',
logo: {
alt: 'My Site Logo',
src: 'img/logo.svg',
},
items: [
{
label: 'Documentation', position: 'left',
items: [
{ label: 'Introduction', to: 'docs/introduction' },
{ label: 'Getting Started', to: 'docs/try-samples' }
]
},
{ to: 'demo', label: 'Live Demo', position: 'left' }, // to src/pages/demo.js
{
label: 'Persons', position: 'left',
items: [
{ label: 'Get my website', to: 'docs/consumer-buy' },
{ label: 'Follow Free Videos and Contents', to: 'docs/free-videos' },
{ label: 'Request a Help', to: 'docs/help-your-work' }
]
},
{
label: 'Businesses', position: 'left',
items: [
{ label: 'Get my website Together', to: 'docs/group-buy' },
{ label: 'Other Services', to: 'docs/web-development' }
]
},
{
label: 'Language and Programming', position: 'left',
items: [
{ label: 'Course in English', to: 'https://go.mywebsite.com/RJ2HPz' },
{ label: 'Course in Chinese', to: 'https://go.mywebsite.com/2KjQzL' },
]
}
,
{
to: '#',
position: 'right',
},
{
to: '/logout',
label: 'Sign Out',
position: 'right',
},
{
to: '/login',
label: 'Sign In',
position: 'right',
},
{
type: 'localeDropdown',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
title: 'Documentation',
items: [
{
label: 'Try samples',
to: 'docs/try-samples',
},
{
label: 'Installation',
to: 'docs/installation',
}
],
},
{
title: 'Philosophy and Research',
items: [
{
label: 'Fundamentals',
to: 'docs/fundamentals'
},
],
},
{
title: 'Community',
items: [
{
label: 'LinkedIn',
href: 'https://www.linkedin.com/in/softtimur/'
}
],
},
{
title: 'Company',
items: [
{
label: 'About Us',
to: 'docs/about-us'
},
{
label: '❤ We are hiring!',
to: 'docs/hiring'
}
],
}
],
},
},
presets: [
[
'@docusaurus/preset-classic',
{
googleAnalytics: {
trackingID: 'UA-68622074-6',
},
docs: {
sidebarPath: require.resolve('./sidebars.js'),
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
sitemap: {
changefreq: 'weekly',
priority: 0.5,
},
},
],
],
scripts : [
'/js/patch.js'
],
i18n: {
defaultLocale: 'en',
locales: ['en', 'zh-CN'], // Add 'zh-CN' here
localeConfigs: {
en: {
label: 'English',
htmlLang: 'en-GB',
},
'zh-CN': { // Add this section for Simplified Chinese
label: '简体中文',
htmlLang: 'zh-Hans',
},
},
}
};
(* stackoverflow: https://stackoverflow.com/questions/75442550 *)
I have a website made by docusaurus
2.0.0-beta.18
. I realize that, in production, when I click on items in the sidebar, it first goes tohttps://www.mywebsite.com/docs/a-page
. If I reload the page, the url becomeshttps://www.mywebsite.com/docs/a-page/
. This problem does not exist in localhost.I think a url should be consistent before and after reloading. And like StackOverflow, a good style is not having
/
in the end. I searched issues of Docusaurus and it seems that trailingSlash would be the solution. So I addedtrailingSlash: false
indocusaurus.config.js
.Then, I deployed this change to my production server with docker and nginx. But loading most of the pages of the website returned a 404 error, while static contents could be loaded. Reloading nginx or recreating docker containers did not help.
By contrast, setting
trailingSlash: true
returns well the website. And it works well: clicking on items in the sidebar goes tohttps://www.mywebsite.com/docs/a-page/
ended with/
.So does anyone know why
trailingSlash: false
makes the website return 404 error?PS: docusaurus.config.js:
nginx configuration:
The text was updated successfully, but these errors were encountered: