#Js not loading on gitlabpage

3 messages · Page 1 of 1 (latest)

sterile mantle
#

Hi, I have the following problem: I'm deploying an astro web in gitlab pages and the html and css loads correctly as well as the routes, but the javascript is not working for my dropdown menu, even though in my localhost it does work, I saw other template that is the same as mine where the dropdown menu works, so I don't know exactly what could be happenning, any ideas?

tender isleBOT
#

Hi @sterile mantle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I don't know enough to give you a confident answer yet. However, Astro emphasizes minimized JavaScript usage and optimized loading times, so it's possible that there might be some differences in how JavaScript is handled between your local development environment and the production build on GitLab Pages.

Here are a few things you could check:

  1. Make sure your JavaScript files are being included in the correct order in your HTML. Sometimes, the order of scripts can affect how they work.

  2. Check if there are any errors in the browser console that might indicate what's going wrong.

  3. Review your astro.config.mjs file to ensure it's correctly configured for deployment on GitLab Pages. According to the Astro documentation (https://docs.astro.build/en/guides/deploy/gitlab/), you should set the site and outDir properties correctly, and if you're using the public/ directory for static files, you might need to rename it and update the publicDir property.

Here's an example of how your astro.config.mjs might look:

import { defineConfig } from 'astro/config';
export default defineConfig({ 
  sitemap: true, 
  site: '<https://astro.build/',> 
  outDir: 'public', 
  publicDir: 'static',
});
  1. Make sure you're using the correct build command in your .gitlab-ci.yml file. The Astro documentation (https://docs.astro.build/en/guides/deploy/gitlab/) provides an example of what this file might look like.

If none of these suggestions help, you might want to consider opening an issue on the Astro GitHub page (https://github.com/withastro/astro/issues) to get help from the Astro community.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: