I am hosting a static application on GitHub pages. My application structure is like this - I have some front-end facing files, and some Python files that are run periodically to get the data for the front-end, but should not be user-facing:
index.html
/js
index.js
vendor/
/css
/data
get_data.py
How can I stop everything in data/ being publicly available on the website?
You have two main options:
Option 1: Rename your data directory to _data.
Jekyll ignores files and directories that start with an underscore. You could also create a top-level _backend directory and then move your data directory into that.
Option 2: Configure your Jekyll to exclude the data directory.
You can add an exclude setting to _config.yml to tell Jekyll to ignore your data directory.
From the configuration documentation:
Exclude
Exclude directories and/or files from the conversion. These exclusions
are relative to the site's source directory and cannot be outside the
source directory.
exclude: [DIR, FILE, ...]
Googling "jekyll underscore directory" returns a ton of results, including this one which explains all of the above: https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/
Related
It seems a straightforward one, but having researched multiple ways to do it, I can't gitignore a folder within a directory.
I have a root directory which contains all of my code in it. Because it has some back-end NodeJS stuff in it, it has a 'node_modules' folder which contains hundreds of files. As a result, when I try to upload the entire parent folder, GitHub says there's too many files to upload and tells me to reduce the number I'm uploading.
The crucial part is though, the folder has to be uploaded as a whole, as it itself is within a GitHub repository with other files with different folders in.
That means when I go onto my repository, I need this folder's files to display within the folder, and not separately within the repository. I need all of the files to be within this folder, within the parent repository, excluding the node_modules folder.
For example ->
Parent repository -> Child Directory (what I'm uploading) -> Individual files
I've tried to add the node_modules folder to my gitignore through the following methods:
Adding: node_modules/ to my gitignore file
Writing: echo node_modules >> .gitignore through my terminal
Adding a separate gitignore file within my node_modules file with a * in it
None of them have worked and I can't find any other solutions. For reference I'm using a Mac.
Does anyone have any idea what I'm doing wrong, or how it'd be best to do it?
By default, you do not need to include the node_modules folder in your repositories because the package.json file contains all of your project's dependency information. This means that anyone who clones your repository can run npm install and have the entire node_modules folder without problems.
To solve this you can create your own .gitignore file, creating a new file at the root of your project and renaming it to .gitignore (writing exactly that way). Then you can open it with any text editor and add */node_modules to one of the lines.
This will likely solve your problem.
I have a requirement in my project where I need to ignore the .html file to track via git in the project however need to track any .html file in a given folder along with its sub folder.
I tried using below code to exclude to track all files from ignore_directory but it didn't worked.
*.html
!ignore_directory/*
What you have is the correct way to exclude a directory.
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor or
# operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
*.html
!ignore_directory/*
Either the path you have is incorrect or is not relative to the directory you want to exclude. It's also possible that the directory you want to exclude contains a gitignore file overriding your exclusion.
Read GitHub help on Ignoring files for a simple introduction to ignoring files and also tead the Git - gitignore documentation.
My index.html (https://srgg6701.github.io/Music-Is-My-Life/) can't see 3 existing .js files, although I can load them directly in raw mode. They are here: https://github.com/srgg6701/Music-Is-My-Life/tree/gh-pages/js/_libs
What may be cause of this?
By default, Jekyll (which GitHub Pages uses to generate your pages) ignores anything that starts with an underscore.
You can change this setting by modifying your settings, as discussed here:
If your GitHub Pages site isn't publishing certain files then you
might need to reformat their titles. If you are using Jekyll you can
create a .nojekyll file or edit the _config.yml file to publish
these files.
By default, Jekyll does not build any files or directories that
are hidden or used for backup (indicated by names that start with . or #, or that end with ~);
contain site content (indicated by names that start with _); or
are excluded in the site configuration.
To work around this behavior, you can
include a .nojekyll file in the root path to turn off Jekyll;
use [the include directive][global-config] in your _config.yml to specify files that should not be ignored; or
do not use file or directory names that start with an underscore (_), period (.), or hash symbol (#), or that end with a tilde
(~).
Every GitHub repo has the Download ZIP button, but is there a way to control what gets into the final zipball. For example we do not need and hidden files there, or even - unit tests.
Excerpt from Pro Git book:
You can tell Git not to export certain files or directories when
generating an archive. If there is a subdirectory or file that you
don’t want to include in your archive file but that you do want
checked into your project, you can determine those files via the
export-ignore attribute.
For example, say you have some test files in a test/ subdirectory, and
it doesn’t make sense to include them in the tarball export of your
project. You can add the following line to your Git attributes file:
test/ export-ignore
Now, when you run git archive to create a tarball of your project,
that directory won’t be included in the archive.
I am creating a new meteor app and would like to put the whole thing under git source control. When cloning a working copy of my meteor directory, meteor gives : run: You're not in a Meteor project directory.
After inspecting the .meteor directory, I see that the files in here are being excluded in my local clone.
Is there a particular reason this is done?
as #Swadq already pointed about, the .meteor directory is Meteor's directory. It contains a folder and a file.
The local directory contains the compiled version of your application and some database information (lock-file and the actual raw data of mongodb). This of course should not be included in your VCS.
The package file contains all packages meteor should load for your application. This is of course important and must be included in your VCS. More importantly: this file is checked for to determine if the current directory is a meteor application. If you don't include this you'll loose the packages you relay on and the ability to simply run the app. using meteor.
So ideally your .gitignore file only should contain .meteor\local but not .meteor\packages. When using meteorite the .gitignore file should contain .meteor\meteorite as well.