Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to place astro-paper in a subdirectory of the website #253

Open
johanazhu opened this issue Jan 28, 2024 · 3 comments
Open

How to place astro-paper in a subdirectory of the website #253

johanazhu opened this issue Jan 28, 2024 · 3 comments
Labels
awaiting reply Waiting for a response from the author to proceed

Comments

@johanazhu
Copy link

Hello, I have a confusion. After I deploy astro-paper to vercel, I want to put the website under xxx.com/blog. When I set it in next.config.js of xxx.com

 async rewrites() {
    return [
      {
        source: '/blog/:subdir*',
        destination: 'http://xxx.com/:subdir*',
      },
      {
        source: '/(.*)',
        destination: '/',
      },
    ];
  },

Style and css error reporting, click on the article, there is no prefix (/blog)

PS:I am a Chinese and my English is not very good.

@benjaminrae
Copy link
Contributor

Have you considered using a subdomain? That would make it https://blog.xxx.com. I see that pattern a lot more and I think it will be much easier to configure

@satnaing
Copy link
Owner

Hello @johanazhu
I might be a little too late. However, here's the solution I can think of.

  1. Add a base and trailingSlash in astro.config.ts
export default defineConfig({
  // others
  base: "/blog",
  trailingSlash: "ignore",
  // others
)}
  1. Then, update all the links to include /blog/ or import.meta.env.BASE_URL at the start.
<a href=`/blog/posts/`>Posts</a>
<link rel="icon" type="image/svg+xml" href="/blog/favicon.svg" />
<script is:inline src=`${import.meta.env.BASE_URL}/toggle-theme.js`></script>

@satnaing satnaing added the awaiting reply Waiting for a response from the author to proceed label Aug 4, 2024
@JeS24
Copy link

JeS24 commented Aug 27, 2024

I have implemented a base URL in my fork that we use at our lab. It basically follows @satnaing's suggestion above. You can take a look here: https://github.com/JeS24/smlab-talks.

P.S.: There are some other changes that were needed in our case. Feel free to ignore those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reply Waiting for a response from the author to proceed
Projects
None yet
Development

No branches or pull requests

4 participants