Himadri Ganguly
Himadri Ganguly

Reputation: 743

Docusaurus page not rendering

Docusaurus rendering the Front Page but not rendering other pages only the URL is changing.

I have just built the default Docusaurus website using yarn run build and uploaded to the Nginx Web server on CentOs 7 but except the Front Page, other pages are not rendering. URL is changing but content doesn't change.

Nginx config

File path:- /etc/nginx/conf.d/app1.conf

limit_req_zone $binary_remote_addr zone=one:10m rate=30r/m;

server {
    listen  80 reuseport;
    server_name  _;
    index index.html;

    # React App
    location / {
        root /usr/share/nginx/app1;
        try_files $uri /index.html =404;
        limit_req zone=one burst=5;
    }

    # Docusaurus App
    location /docs {
        root /usr/share/nginx/docs;
        try_files $uri $uri/index.html /index.html =404;
        limit_req zone=one burst=5;
    }

    location ~* .(jpg|jpeg|png|gif|ico|css|js|svg)$ {
        root /usr/share/nginx/;
        expires 365d;
    }
}

Docusaurus - Version 1.11.1

File path:- siteConfig.js

/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

// See https://docusaurus.io/docs/site-config for all the possible
// site configuration options.

// List of projects/orgs using your project for the users page.
const users = [
  {
    caption: 'User1',
    // You will need to prepend the image path with your baseUrl
    // if it is not '/', like: '/test-site/img/image.jpg'.
    image: '/docs/img/undraw_open_source.svg',
    infoLink: 'https://www.facebook.com',
    pinned: true,
  },
];

const siteConfig = {
  title: 'Test Site', // Title for your website.
  tagline: 'A website for testing',
  url: 'https://your-docusaurus-test-site.com', // Your website URL
  baseUrl: '/docs/', // Base URL for your project */
  // For github.io type URLs, you would set the url and baseUrl like:
  //   url: 'https://facebook.github.io',
  //   baseUrl: '/test-site/',

  // Used for publishing and more
  projectName: 'test-site',
  organizationName: 'facebook',
  // For top-level user or org sites, the organization is still the same.
  // e.g., for the https://JoelMarcey.github.io site, it would be set like...
  //   organizationName: 'JoelMarcey'

  // For no header links in the top nav bar -> headerLinks: [],
  headerLinks: [
    {doc: 'doc1', label: 'Docs'},
    {doc: 'doc4', label: 'API'},
    {page: 'help', label: 'Help'},
    {blog: true, label: 'Blog'},
  ],

  // If you have users set above, you add it here:
  users,

  /* path to images for header/footer */
  headerIcon: 'img/favicon.ico',
  footerIcon: 'img/favicon.ico',
  favicon: 'img/favicon.ico',

  /* Colors for website */
  colors: {
    primaryColor: '#980c77',
    secondaryColor: '#6a0853',
  },

  /* Custom fonts for website */
  /*
  fonts: {
    myFont: [
      "Times New Roman",
      "Serif"
    ],
    myOtherFont: [
      "-apple-system",
      "system-ui"
    ]
  },
  */

  // This copyright info is used in /core/Footer.js and blog RSS/Atom feeds.
  copyright: `Copyright © ${new Date().getFullYear()} Your Name or Your Company Name`,

  highlight: {
    // Highlight.js theme to use for syntax highlighting in code blocks.
    theme: 'default',
  },

  // Add custom scripts here that would be placed in <script> tags.
  scripts: ['https://buttons.github.io/buttons.js'],

  // On page navigation for the current documentation page.
  onPageNav: 'separate',
  // No .html extensions for paths.
  cleanUrl: true,

  // Open Graph and Twitter card images.
  ogImage: 'img/undraw_online.svg',
  twitterImage: 'img/undraw_tweetstorm.svg',

  // Show documentation's last contributor's name.
  // enableUpdateBy: true,

  // Show documentation's last update time.
  // enableUpdateTime: true,

  // You may provide arbitrary config keys to be used as needed by your
  // template. For example, if you need your repo's URL...
  //   repoUrl: 'https://github.com/facebook/test-site',
};

module.exports = siteConfig;

Upvotes: 0

Views: 3402

Answers (1)

Yangshun Tay
Yangshun Tay

Reputation: 53179

I don't think the baseUrl for your site should be '/docs/'. Typically it should only be '/'. For example, if you're hosting it on a domain with no subpath, then you should use '/'.

If that's not the reason, then it should be something to do with your Nginx configuration. Docusaurus 1 is not a single-page application (see the build), so you should serve it like a file directory instead of redirecting all requests to the root of the web app.

Upvotes: 1

Related Questions