Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I keep my site media in my website's repository?

I have a simple blog application written in Python, using Django. I use Git to version-control this website. The main content of the site is a blog. The blog entries are stored in a SQLite database (which is not version-controlled, but is backed up regularly); some entries contain images and other media (like PDFs).

I currently store this "blog media" in the repository, alongside other media (such as external JavaScript code, and images used for layout purposes -- all nicely organized, of course). It occurred to me, however, that this isn't really a good strategy, for a few reasons:

  1. Whenever I post a new blog entry that contains an image or a link to a PDF, I have to add the image to the repo and then copy a new version to the production server -- which seems like a lot of work just to add an image. It'd be easier just to upload the image to the server (and make a local backup, of course).
  2. Since this media is content rather than code, it doesn't seem necessary to store it alongside the code (and related style media) itself.
  3. The repo contains a lot of binary files, which increase the overall size of the repo; and more importantly,
  4. I never really edit these images, so why keep them under version-control?

So I'm considering removing these files from the repo, and just copying them to a directory on the server outside of the directory containing the Python code, templates, style sheets, etc., for the website.

However, I wondered: Is there a "best practice" for dealing with content images and other media in a website's repo, as opposed to images, etc., that are actually used as part of the site's layout and functionality?


Edit

To elaborate, I see a difference between keeping the code for the website in the repo, and also keeping the content of the site in the repo -- I feel that perhaps the content should be stored separately from the code that actually provides the functionality of the site (especially since the content may change more frequently, and I don't see a need to create new commits for "stuff" that isn't necessary for the functioning of the site itself).

like image 565
mipadi Avatar asked Feb 28 '23 23:02

mipadi


2 Answers

Keep them in version control. If they never change, you don't pay a penalty for it. If they do change, well, then it turns out you needed the version control after all.

like image 157
flodin Avatar answered Mar 27 '23 03:03

flodin


Initially, I would say don't put them in the repo because they'll never change but then consider the situation of moving your website to a different server, or hosting provider. You'd need an easy way to deploy it, and unless it's not under version control, that's a lot of copy/paste that could go wrong. At least it's all in once place if/when something happens.

This isn'y really an answer as much as it's something to consider.

like image 31
Steven Evers Avatar answered Mar 27 '23 03:03

Steven Evers