In order to simplify your application code, and remove redundant view logic, replace your two questions variables with a hash that contains multiple keys. The hash keys should be identical to the section headings in your view.
Once your data is moved into a hash, you'll need to modify your view code to iterate over each of the key value pairs in the hash.
require 'rubygems'
require 'sinatra'
require 'mechanize'
get '/' do
agent = Mechanize.new
agent.get('http://stackoverflow.com/questions/tagged/ruby')
@rubyQuestions = agent.page.search('.question-hyperlink')
agent.get('http://stackoverflow.com/questions/tagged/git')
@gitQuestions = agent.page.search('.question-hyperlink')
erb :index
end
<html>
<link rel="stylesheet" href="/bootstrap.min.css">
<body>
<h3 class="text-center" style="text-decoration:underline">Ruby Questions</h3>
<ul class="unstyled text-center">
<% @rubyQuestions.each do |question| %>
<li><a href="http://stackoverflow.com<%= question.attributes['href'] %>" ><%= question.text %></a></li>
<% end %>
</ul>
<hr>
<h3 class="text-center" style="text-decoration:underline">Git Questions</h3>
<ul class="unstyled text-center">
<% @gitQuestions.each do |question| %>
<li><a href="http://stackoverflow.com<%= question.attributes['href'] %>" ><%= question.text %></a></li>
<% end %>
</ul>
</body>
</html>