faulty path to css file in octopress generation - html

I'm just getting started with Octopress; pretty green on web development, and I'm having the following issue:
When I run rake generate to make my octopress page, it mostly generates everything fine but it's not giving a good reference to the .css file. Here is the link it generates:
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
This leaves my index.html page with bare html formatting. But if I change the link to read:
<link href="stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
it works. All I did was take out the forward slash.
My question is this: what do I need to change for rake generate to put the proper reference in the html file?

A slash in front will point to the root directory of the project.
Whereas without slash, it will point to the current directory of the HTML file
So if in your case, project structure is:
Project/something/index.html
Any link with "/stylesheets/" will point to a folder in the Project directory. ie it will look for "Project/stylesheets"
Whereas a link with "stylesheets/" will point to a folder in the something directory, which is the current directory of the project.

You need to edit your Rakefile.
I wrote an article about Rake commands in Octopress here:
http://www.tomordonez.com/blog/2013/03/12/rake-commands-in-octopress-on-github/
Inside your main Octopress directory there should be a file called "Rakefile"
Open this file and look for this line:
desc "Generate jekyll site
task :generate do
In here there is a line that says:
system "compass compile -css-dir #{source_dir}/stylesheets"
The source_dir is assigned toward the top of the Rakefile where it says ## Misc Configs ##.
It should say:
source_dir = "source"
I gave you almost all the solution. Put these together and try it out to see if you can make it work :)

Since you're new, I'll give you some ideas as to how this can work
--
Assets
Firstly, when you make use of the asset piepline in Rails, it does a lot of the work for you. Specifically, the stylesheet feature is very well documented:
<%= stylesheet_link_tag "screen" %>
If your page has hard-coded references to your stylesheets, it's going to cause all sorts of compatibility issues down the line (with production etc).
I know this is not an answer to your question directly, but you need to ensure your HTML files are making use of the Rails helper methods - these create dynamic paths, which your app will automatically follow
--
Generate
As for your generator, I've got no experience with octopress
If the gem is not written by you, I would not worry about the generator too much. Having written my own gems & other software, it's very difficult to create a system which works for every single system
If you have the ability to change the path yourself (after generation), I'd do that, and raise an issue with the author on Github

Related

Is it possible to add a single custom HTML page to an existing Hugo theme like Academic?

What do you want exactly?
I have a website in Hugo. However I have a peculiar situation.
Scientists and Electrical Engineers and others may have specific needs. For Eg: Having a single page that shows a simulation. Or in my case using webbluetooth and webusb that I have written from scratch in HTML, CSS and JS. Moreover these pages may be generated by custom scripts. So you can have git submodules inside your hugo site that specifically cater to generating these custom, single page html that you just want to add to your website.
So all I want is to have a menu item or sidebar whatever the existing theme supports, but instead of showing the default html, it should show my custom, hard-coded, already ready and prepared html file - which may as well be an index.html file in a folder with all the necessary contents ready and cooked - something like the _site folder that jekyll creates.
What do you mean by custom html?
I mean it doesn't take the formatting of the hugo theme. It has its own formatting, but because its just a single page in the whole website its not fruitful to have its own layout written in Hugo or maybe its just worth the effort to do that cause you already have it working using some other technology.
What have you done so far and what works?
I am actually coming from a Jekyll background where it's as simple as changing the layout frontmatter and making it nil or even something that doesn't exist at all and jekyll does a great job of showing custom HTML in an existing theme. Tried the same with Hugo but that didn't work.
What are you testing on?
hugo-coder and(or) hugo-academic
Any specific requests?
Ideally I would like to have submodules in my hugo site folder where those submodules generate custom html in known folders and then somehow make a corresponding markdown file in Hugo that is responsible for showing the custom html.
I want to avoid writing the whole html in the markdown itself. But if no other solution is possible then I guess I don't have a choice.
Do let me know if its possible and worthwhile to pursue this and any references that might help.
So I don't know if this is the perfect solution but it somehow works for the moment. I will not accept it as its not perfect and I am waiting for some of the more experienced folks to answer.
I got something working by doing the following -
I had a page built using Jekyll. Jekyll builds the site in a folder called _site.
I copied the _site folder into static folder of Hugo and renamed it correspondingly to CustomHTML OR you could use the flag -d <destination folder> or declare it in the _config.yml file : destination: <destination folder>
Since I am testing it on hugo-acdemic theme, for that I added the following to the config.toml file to show it in the menu -
[[menu.main]]
name = "CustomHTML"
url = "CustomHTML/index.html"
weight = 50
hugo serve And it worked.
Cool thing is that I didn't have to bother about CSS and anything else. Hugo rendered the index.html in _site properly.
EDIT
Looks like the Hugo folks also suggest doing the same way.

Wrong site root when testing web page from NetBeans

This is a really basic one, I'm afraid, but it's driving me crazy.
I'm making a website using NetBeans. I have my index.html in the Site Root folder that NetBeans gives you, and when I test it with the Chrome plugin, it comes up successfully.
However, if I load CSS by absolute path, <link rel="stylesheet" type="text/css" href="/layout.css" />, it doesn't load properly, because NetBeans runs the local server within a folder with the same name as the project.
What I mean is, instead of NetBeans loading the website from http://localhost:8383/index.html, it instead loads it from http://localhost:8383/ProjectName/index.html and breaks all the paths.
The "site root" setting is set to public_html, which contains index.html directly.
This is the annoying kind of problem to which there is probably a really easy solution that I'm missing. Any help is very much appreciated!
Have you tried using a relative URL to the CSS file?
Like:
<link rel="stylesheet" type="text/css" href="layout.css" />
Note! This solution is working for one Neatbean project (site) at a time so it is not ideal but maybe good enough for many others. If someone have a solution that works for multiple projects I'm very interested in that solution as well.
Set your server configuration to serve documents from your Netbean project folder, in XAMPP it looks like this.
Set your Netbean project URL to "http://localhost/"
Now links starting with "/" will lead to your root as expected but if you switch project you will also need to do step 1 again.
Apache Netbeans 12.1.
Right click on project - > Properties - > Run. Set Web Root to /
Benefits: paths relative to the root are properly working.
Disadvantages: impossible to work on several projects simultaneously.

CSS - Failed to load resource: the server responded with a status of 404 ()

I am trying to load my simple website online hosted by Github.io. However, after countless and frustrating efforts of troubleshooting and debugging the HTML & CSS script, my web still couldn't get the CSS file loaded as desired for some really mysterious and extremely annoying reason.
Don't get me wrong:
I swear my CSS file is put in the absolute path rather than the relative path as I firstly put it, so I will smash myself if it's the cause of the error.
After a while couldn't figure out, I looked over similar or related issues posted on stackoverflow as well, some suggest that the access permission is maybe the reason, but I followed them with the command inside my directory of CSS file
chmod -R 777
But I don't see it resolves as well cuz the command has no effect, and I didn't run it at the root level
I inspected this web on both Chrome and Safari, and the style.css is blank as it couldn't be loaded!!!
Now, I keep hold on this to wait for any of your "magic" helps. I deeply appreciate the help, as I tried my best fixing it already, but didnt work.
Here is the just HTML link tag line where the file is not loaded.
<head>
....
<link rel="stylesheet" href="./_css/style.css">
</head>
If your _css directory is in the root, your CSS link should start with a slash:
<link rel="stylesheet" href="/_css/style.css">
But naming your directory _css may be a problem. Github Pages by default treats your site as a Jekyll website, which processes your files and does not publish files/directories having _ prefix.
I think you have 2 options:
If you don't know about Jekyll and you are not creating a Jekyll site, put a file in your root named .nojekyll to bypass Jekyll processing.
Rename your directory from _css to css and also modify your <link> tag.

File exists but, Status 404 File not Found

First of all, I'm using Chrome browser for development.
I have placed the files in the following order:
In Markup, I placed its reference like this:
<link href="App_Data/css/bootstrap.min.css" rel="stylesheet" />
This is the original path: root/App_Data/css/bootstrap.min.css.
The file is available at the path, but still, the browser can't find the file with an error shown in the picture below:
I am confused. Why is it not able to find the file from the correct path? :S
What mistake am I making? (My previous question was also about the path. I tried following my last question's guide, but that also is not resolving this issue. Please look into it and tell me the possible issues. Thank you).
App_Data is not typically used to publish web content, and is not published by default.
I'm sure App_Data is a special folder in MVC, consider moving the files in to a "content" folder or something (as is the standard).
Also try prefixes like "./" or "/" or "../" as depending on the url of the current page you may want to have a different path for these resources or always generate one that's relative from the root of the site.
I've just found a solution with the help of someone who commented here but deleted the comment. He was correct! I couldn't see his nickname. I'd prefer him to answer, i'll Tick his answer.
APP_data folder in asp.net doesn't let browser load Css and JS files as this folder is standard for Class files e.g. ( abc.cs ) .
I just moved all of these files in a new folder i created with the name Content and moved all css and js files in it, referenced it in Html and it worked like a charm.
Try relative path as below, it might help you-
<link href="../css/bootstrap.min.css" rel="stylesheet" />
You have to start with the root of your application.App_Data is just a folder in Microsoft Visual Studio context.Once you publish your app it will not be the same.
For your question, this would be the solution:
<link href="/css/bootstrap.min.css" rel="stylesheet" />
This will resolve the path from the app root.

Making a relative path HTML Shortcut

I have pretty much no experience with HTML, but I am using Doxygen to create code documentation. I have all the Doxygen generated HTML files in a sub-directory within my C project.
This documentation is for a library I have built and I would like the user to be able to view the HTML documentation without having to search through the Doxygen sub-directory for index.html. I tried to make a Windows shortcut to index.html, but that only works on my working computer. Whenever I try on another computer, Windows requests the username and password of my working computer. Then I tried copying the index.html file to the top-level of my library; however, in doing so, it seems like many links were broken and the file did not open properly.
Please note that I am not looking to host this documentation on a server, the documentation will be distributed with the source code, since this library is (currently) for internal, educational university use and I am not sure if I am allowed to make it open-source.
In other words, this is the type of file structure I'm looking for:
Project Folder
-Doxygen Documentation Folder
-index.html
-Source Code Folder
-Shortcut to index.html
There's a thread here that should help.
Essentially the suggestion is to have a top-level index.html that links or redirects the reader to the one in the doxygen folder. I note you're new to HTML but it's quite simple.
There's an example of a minimal index.html you could use towards the bottom of that thread which I'll replicate here in case that thread ever disappears. It was contributed by Clemens Feige.
<head>
<meta http-equiv="refresh" content="1; URL=doxygen/index.html">
</head>
<body>
<p>You will be redirected automatically, otherwise please click here.</p>
</body>
You'll need to tweak the paths according to your set-up.
I ended up using this software But I think I like Cheeseminer's solution better