Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8436809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:17:02+00:00 2026-06-10T07:17:02+00:00

I have a site hosted by GitHub Pages that uses Jekyll, and I’ve been

  • 0

I have a site hosted by GitHub Pages that uses Jekyll, and I’ve been successfully using an internally defined script in each layout that will generate a random tagline from an array of them.

I’m trying to move this script to an external tagline.js, but so far I’ve been unsuccessful.

Here’s the basic tagline generating script, in case there’s something in the code causing this (which I doubt, honestly, due to its simplicity; but it’s always a possibility):

var tags = [ 'tag1', 'tag2', 'tag3' ];

function getTag() {
    return tags[Math.floor(Math.random() * tags.length)];
}

$(document).ready(function() {
    $("#tagline").text(getTag());
});

Like I said, it works fine when it’s internal, but it doesn’t when I try linking to external. I’m pretty sure it’s just a case of where I’m pointing the <script> to: the HTML file containing the <script> is in _layouts/default.html, but the script is in scripts/tagline.js:

<script type="text/javascript" href="../scripts/tagline.js"></script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:17:03+00:00Added an answer on June 10, 2026 at 7:17 am

    The attribute you want to use for a script call is src instead of href. For example:

    <script type="text/javascript" src="../scripts/tagline.js"></script>
    

    I would also highly recommend using paths from the site root (aka docroot) instead of relative to the file. That way you can use the same call in multiple places and it will always hit the correct location. To use a docroot relative URL, you start the path with a /.

    Assuming your script is located at http://example.com/scripts/tagline.js, the call you would make is:

    <script type="text/javascript" src="/scripts/tagline.js"></script>
    

    Without using the docroot, you will constantly have to adjust the path depending on where the HTML file calling the script is located in the tree. If all the files are in the same place, that’s not a big deal, but it’s a good habit to get into to avoid issues down the road.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a classic ASP site that is been hosted in IIS 7.5. I
We have a site hosted in IIS6 that we built using the .NET 1.1
Ok - long story short. Have an e-comm site hosted on Windows VPS using
I have my site hosted on IIS hosting. Site has feature that needs calling
I have a site that is hosted in shared hosting environment. They use a
I have a site hosted on IIS6 server. All the pages with specific url
I have a site that is hosted on inmotion hosting and requires a phpMailer
I have a site developed in ASP.NET and hosted on a windows server using
I have a site hosted in http:// www.domain1.com This domain loads a script located
I have a site [hosted on DreamHost], using WordPress for the main content, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.